I am assuming that STS is successfully setup with the Maven and Subclipse plugins. I am running my STS On Ubuntu 10 platform. Some of you may have problems with Subclipse Native connector, just change that to use pure java SVNKit instead.I am sorry I am not going through the design architecture phase but straightway jumping into the project. This is intentional as my goal is see how easy or difficult it is to create a Spring 3 web application progressibly which is highly pluggable, easy to extend, customize and manage.
Launch STS and create a maven web project using (maven-archetype-webapp). The project was named ecrm.
Step 1 : Modify the pom file as shown below:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.effectivcrm</groupId>
<artifactId>ecrm</artifactId>
<packaging>war</packaging>
<version>0.0.5</version>
<name>ecrm</name>
<url>http://maven.apache.org</url>
<properties>
<!-- ~~~~~~ -->
<!-- System -->
<!-- ~~~~~~ -->
<jdk.version>1.6</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Version dependencies when used in multiple dependencies -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<spring.version>3.1.2.RELEASE</spring.version>
<spring-security.version>3.1.2.RELEASE</spring-security.version>
<spring-webflow.version>2.3.1.RELEASE</spring-webflow.version>
<slf4j.version>1.5.10</slf4j.version>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Variables substituted in resources file at build time -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<application.name>${project.name}</application.name>
<application.version>${project.version}</application.version>
<application.description>${project.description}</application.description>
</properties>
<developers>
<developer>
<name>Dhrubo</name>
<email>info@effectivcrm.com</email>
<organization></organization>
<organizationUrl></organizationUrl>
</developer>
</developers>
<!-- ~~~~~~~~~~~~ -->
<!-- DEPENDENCIES -->
<!-- ~~~~~~~~~~~~ -->
<dependencies>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- List your specific dependencies below -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- ~~~~~~ -->
<!-- LOGGER -->
<!-- ~~~~~~ -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- ~~~~~~ -->
<!-- SPRING -->
<!-- ~~~~~~ -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.12</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.12</version>
</dependency>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- SPRING MVC -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- THEMEYLEAF -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.0.12</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring3</artifactId>
<version>2.0.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.effectivcrm</groupId>
<artifactId>view</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
<!-- ~~~~~~~~~~~~ -->
<!-- REPOSITORIES -->
<!-- ~~~~~~~~~~~~ -->
<repositories>
<repository>
<id>repository.entral.org</id>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
</repository>
<repository>
<id>springsource-repo</id>
<name>SpringSource Repository</name>
<url>http://repo.springsource.org/release</url>
</repository>
<repository>
<id>jboss-public-repository-group</id>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</repository>
<repository>
<id>java.net-maven</id>
<name>java.net-maven</name>
<url>http://download.java.net/maven/2</url>
</repository>
</repositories>
<build>
<finalName>ecrm</finalName>
</build>
</project>
Step 2: Modify the web.xml to support Servlet 3.0 on Tomcat 7.x
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<!-- Log4j -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>file:${catalina.home}/temp/effectivcrm/conf/log4j.xml</param-value>
</context-param>
<context-param>
<param-name>log4jExposeWebAppRoot</param-name>
<param-value>false</param-value>
</context-param>
<!-- Log4j listerner -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<servlet>
<servlet-name>Spring MVC 3 Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:conf/spring-*-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Spring MVC 3 Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
Note dispatcher servlet parameter contextConfigLocation. It sets up the dispatcher servlet to load configuration files from classpath in a modular way. Thats is from respective jars - for view, controllers, service, domain, repository etc.
Related Posts:
Comments
Post a Comment