How to import Java-config class into XML-config so that both contexts have beans?

This actually ended up being fairly simple. To get a Java-config bean definition into the xml-config, simply define the Java-config class as a bean within the XML-config. There are no extra jars necessary. @Configuration public class SomeJavaConfig { @bean … [bean definition] } inside the XML-config, you define this class as a bean. <!– needed … Read more

The request sent by the client was syntactically incorrect.-Spring MVC + JDBC Template

I think the issue is that Spring doesn’t know how to deserialize the date your browser client sends when submitting the following input field in <tr name=”tstest”> <td>Date Of Birth</td> <td><form:input path=”dateOfBirth” name=”timestamp” value=””/> <a href=”“document.tstest.timestamp’, document.tstest.timestamp.value);”><img src=”../images/cal.gif” width=”16″ height=”16″ border=”0″ alt=”Click Here to Pick up the timestamp”></a> </td> </tr> Spring doesn’t know how to … Read more

dynamically declare beans at runtime in Spring

The common way to have different beans in the application context is using profiles. You can read about profiles in the following spring source posts: About your first question, you can declare beans at runtime via BeanDefinitionRegistry.registerBeanDefinition() method, for example: BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(SomeClass.class); builder.addPropertyReference(“propertyName”, “someBean”); // add dependency to other bean builder.addPropertyValue(“propertyName”, … Read more

Java 8 Spring compatibility

Basically Spring 3.x versions supports up to Java-7 only. If you want to migrate to Java-8 you should use Spring 4.x version. However some spring release notes says that the Spring Framework 3.2.x will support deployment on JDK 8 runtimes for applications compiled against JDK 7 (with -target 1.7) or earlier. Note that it won’t … Read more

spring autowiring not working from a non-spring managed class

You can use this way to use spring bean in non-spring bean class import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; @Component public class ApplicationContextUtils implements ApplicationContextAware { private static ApplicationContext ctx; @Override public void setApplicationContext(ApplicationContext appContext) { ctx = appContext; } public static ApplicationContext getApplicationContext() { return ctx; } } now you can get the applicationcontext … Read more

Inject and Resource and Autowired annotations

The difference between @Inject vs. @Autowire vs. @Resource? @Autowired: spring propriety annotation (as opposed to @Inject and @Resource) that inject a resource by-type, i.e. by the class of by the interface of the annotated field or contractor. In case we have few implementation of an interface or a subclass we can narrow down the selection … Read more

What is Dependency Injection and Inversion of Control in Spring Framework?

Spring helps in the creation of loosely coupled applications because of Dependency Injection. In Spring, objects define their associations (dependencies) and do not worry about how they will get those dependencies. It is the responsibility of Spring to provide the required dependencies for creating objects. For example: Suppose we have an object Employee and it … Read more