Category Archives: Spring

Choose 'better' or more familiar technologies for a new project?

Questions: I am looking to start work on a brand-new project, something I’ve been thinking about for a while as my first independent sellable project. It’s broadly speaking a web-based service application, and my first choice, server-language is quite easy… I know Java pretty well from working on Java web-apps in the past. However my… Read More »

Nested transaction on Spring

Questions: I found some strange behavior when using nested Spring transactions: when, in the same class, a method annotated as @Transactional calls another method also annotated as @Transactional the second annotation is not used. Let’s consider the following class: public class Main { public static void main(String[] args) { ApplicationContext context = new AnnotationConfigApplicationContext(Config.class); final… Read More »

How to override during production in Spring-Boot?

Questions: I’m using spring boot and to select a database during development by @Configuration @Profile(“dev”). spring.config.location=file:d:/ During production I’d like to create a file outside of the application context that should be loaded and then active a different configuration profile, with d:/ Result: when I start the app, the configuration is still… Read More »

Spring RedisTemplate : Serialise multiple Model classes into JSON.Need to use Multiple RedisTemplates?

Questions: I am using Spring Redis support to save my objects in Redis. I have several DAOs which handle different Model classes : eg : ‘ShopperHistoryDao’ which will save/retrieve objects of ‘ShopperHistoryModel’ ‘ShopperItemHistoryDao’ which will handle objects of ‘ItemHistoryModel’ I want to use ‘JacksonJsonRedisSerializer’ to serialise/deserialize my objects to/from json. But in the constructor of… Read More »

Waiting for all threads to finish in Spring Integration

Questions: I have a self-executable jar program that relies heavily on Spring Integration. The problem I am having is that the program is terminating before the other Spring beans have completely finished. Below is a cut-down version of the code I’m using, I can supply more code/configuration if needed. The entry point is a main()… Read More »

java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication Maven

Questions: I’m trying to create a spring mvc application. This is my pom.xml <?xml version=”1.0″ encoding=”UTF-8″?> <project xmlns=”″ xmlns:xsi=”” xsi:schemaLocation=””> <modelVersion>4.0.0</modelVersion> <groupId>com.acme</groupId> <artifactId>test</artifactId> <name>springmvc</name> <packaging>jar</packaging> <version>1.0.0-BUILD-SNAPSHOT</version> <properties> <org.springframework-version>3.1.1.RELEASE</org.springframework-version> <org.aspectj-version>1.6.10</org.aspectj-version> <org.slf4j-version>1.6.6</org.slf4j-version> </properties> <repositories> <repository> <id>spring-milestone</id> <url></url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>spring-milestone</id> <url></url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> <dependencies> <!– Spring –> <dependency>… Read More »

How to enforce loading order of spring configuration classes?

Questions: I’m working with spring-boot on a multi module project (maven). Each module has it’s own @Configuration class. Basically I do have the following layout Module foo-embedded (runs just calls the method: @Configuration @EnableAutoConfiguration @ComponentScan(“de.foobar.rootpackage”) @Import({ApplicationConfig.class, RepositoryConfig.class, SecurityConfig.class}) public class FooApplication { public static void main(String[] args) throws Exception {, args); } }… Read More »

Cannot JUnit test using Spring

Questions: My test is defined as follows: package com.mytest; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration public class SpringTestCase { @Test public void testSave_success() { fail(“Not implemented”); } } My intention is to just run this test and fail! My test’s spring configuration file is located in: /com/mytest/SpringTestCase-context.xml The contents of my spring configuration file are as follows: <?xml version=”1.0″… Read More »

Spring-Data-Rest Validator

Questions: I have been trying to add spring validators to a spring-data-rest project. I followed along and setup the “getting started” application via this link: …and now I am trying to add a custom PeopleValidator by following the documents here: My custom PeopleValidator looks like package hello; import org.springframework.validation.Errors; import org.springframework.validation.Validator; public class… Read More »