Using Spring in a web application, we need to load the context when the application starts. Fortunately, it can be done in a simple way, by adding the right listener in the application web.xml. Using Maven, you need to add the Spring-web dependency in your pom.xml: <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>4.0.0.RELEASE</version> <scope>compile</scope> </dependency> And in the… Continue reading Starting of Spring context in web application
Category: Java
Check Generic type
Using JMS which is not implemented with Generics, I decided to add some “genericity”. The problem is that, because of type erasure, I can’t use the simple instanceof operator, the solution I used is to pass the class of the Generic when I use it: import java.io.Serializable; public class Handler { public Handler() { super();… Continue reading Check Generic type
Define the Java version in Maven
Directly in the pom.xml (resource definition is also included): <?xml version=”1.0″ encoding=”UTF-8″?> <project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”> … <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>**/*</include> </includes> <excludes> <exclude>profiles/**</exclude> </excludes> </resource> <resource> <directory>src/main/resources/profiles/${profile.name}</directory> <includes> <include>*.properties</include> <include>*.xml</include> </includes> </resource> </resources> </build> </project>