Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Commit cb9ed72

Browse files
committed
Add template for webapp with Java config
1 parent c43fce9 commit cb9ed72

File tree

10 files changed

+363
-0
lines changed

10 files changed

+363
-0
lines changed

SPR-0000-war-java/README.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
This is a simple template for creating issue reproduction projects per
2+
the README.markdown file in the root of this repository (and at
3+
https://github.com/cbeams/spring-framework-issues#readme). Please read
4+
that document completely before starting.
5+
6+
As described at the link above, copy this project to a new directory
7+
having the same name as the JIRA issue you're trying to reproduce and
8+
edit from there.
9+
10+
Both Gradle (build.gradle) and Maven (pom.xml) build scripts are
11+
included for your convenience and choice. Once you've created your
12+
copy of this directory, delete whichever build script you don't wish
13+
to use, and then edit the remaining one to suit your needs.
14+
15+
Note that this project contains a log4j.properties file in
16+
src/test/resources that you may wish to configure to emit more detailed
17+
logging. The log level for org.springframework is set to WARN by default.

SPR-0000-war-java/build.gradle

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
group = 'org.springframework.issues'
2+
version = '1.0.0.SNAPSHOT'
3+
4+
apply plugin: 'java'
5+
apply plugin: 'eclipse'
6+
apply plugin: 'idea'
7+
8+
repositories {
9+
mavenLocal()
10+
mavenRepo urls: 'http://repo.springsource.org/libs-snapshot'
11+
mavenCentral()
12+
}
13+
14+
dependencies {
15+
compile 'org.springframework:spring-context:3.2.0.BUILD-SNAPSHOT'
16+
compile 'commons-logging:commons-logging:1.1.1'
17+
compile 'log4j:log4j:1.2.16'
18+
testCompile 'junit:junit:4.8'
19+
}
20+
21+
[compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:all']
22+
23+
sourceCompatibility = 1.6
24+
targetCompatibility = 1.6

SPR-0000-war-java/pom.xml

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.springframework.issues</groupId>
5+
<artifactId>SPR-0000-war-java</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>Spring MVC Issue Reproduction Project</name>
8+
<packaging>war</packaging>
9+
10+
<properties>
11+
<java-version>1.6</java-version>
12+
<org.springframework-version>3.2.0.BUILD-SNAPSHOT</org.springframework-version>
13+
<org.slf4j-version>1.6.1</org.slf4j-version>
14+
</properties>
15+
16+
<dependencies>
17+
<!-- Spring Framework -->
18+
<dependency>
19+
<groupId>org.springframework</groupId>
20+
<artifactId>spring-context</artifactId>
21+
<version>${org.springframework-version}</version>
22+
<exclusions>
23+
<!-- Exclude Commons Logging in favor of SLF4j -->
24+
<exclusion>
25+
<groupId>commons-logging</groupId>
26+
<artifactId>commons-logging</artifactId>
27+
</exclusion>
28+
</exclusions>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.springframework</groupId>
32+
<artifactId>spring-webmvc</artifactId>
33+
<version>${org.springframework-version}</version>
34+
</dependency>
35+
36+
<!-- CGLIB, required for @Configuration usage -->
37+
<dependency>
38+
<groupId>cglib</groupId>
39+
<artifactId>cglib-nodep</artifactId>
40+
<version>2.2</version>
41+
</dependency>
42+
43+
<!-- Logging -->
44+
<dependency>
45+
<groupId>org.slf4j</groupId>
46+
<artifactId>slf4j-api</artifactId>
47+
<version>${org.slf4j-version}</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.slf4j</groupId>
51+
<artifactId>jcl-over-slf4j</artifactId>
52+
<version>${org.slf4j-version}</version>
53+
<scope>runtime</scope>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.slf4j</groupId>
57+
<artifactId>slf4j-log4j12</artifactId>
58+
<version>${org.slf4j-version}</version>
59+
<scope>runtime</scope>
60+
</dependency>
61+
<dependency>
62+
<groupId>log4j</groupId>
63+
<artifactId>log4j</artifactId>
64+
<version>1.2.16</version>
65+
<scope>runtime</scope>
66+
</dependency>
67+
68+
<!-- Servlet API -->
69+
<dependency>
70+
<groupId>javax.servlet</groupId>
71+
<artifactId>servlet-api</artifactId>
72+
<version>2.5</version>
73+
<scope>provided</scope>
74+
</dependency>
75+
76+
<!-- JSP API and JSTL
77+
<dependency>
78+
<groupId>javax.servlet.jsp</groupId>
79+
<artifactId>jsp-api</artifactId>
80+
<version>2.1</version>
81+
<scope>provided</scope>
82+
</dependency>
83+
<dependency>
84+
<groupId>javax.servlet</groupId>
85+
<artifactId>jstl</artifactId>
86+
<version>1.2</version>
87+
</dependency>
88+
-->
89+
90+
<!-- Apache Tiles
91+
<dependency>
92+
<groupId>org.apache.tiles</groupId>
93+
<artifactId>tiles-jsp</artifactId>
94+
<version>2.1.3</version>
95+
<exclusions>
96+
<exclusion>
97+
<groupId>commons-logging</groupId>
98+
<artifactId>commons-logging-api</artifactId>
99+
</exclusion>
100+
</exclusions>
101+
</dependency>
102+
-->
103+
104+
<!-- JSR 303 with Hibernate Validator
105+
<dependency>
106+
<groupId>javax.validation</groupId>
107+
<artifactId>validation-api</artifactId>
108+
<version>1.0.0.GA</version>
109+
</dependency>
110+
<dependency>
111+
<groupId>org.hibernate</groupId>
112+
<artifactId>hibernate-validator</artifactId>
113+
<version>4.1.0.Final</version>
114+
</dependency>
115+
-->
116+
117+
<!-- Joda Time Library
118+
<dependency>
119+
<groupId>joda-time</groupId>
120+
<artifactId>joda-time</artifactId>
121+
<version>1.6.2</version>
122+
</dependency>
123+
<dependency>
124+
<groupId>joda-time</groupId>
125+
<artifactId>joda-time-jsptags</artifactId>
126+
<version>1.0.2</version>
127+
<scope>runtime</scope>
128+
</dependency>
129+
-->
130+
131+
<!-- Apache Commons File Upload
132+
<dependency>
133+
<groupId>commons-fileupload</groupId>
134+
<artifactId>commons-fileupload</artifactId>
135+
<version>1.2.2</version>
136+
</dependency>
137+
<dependency>
138+
<groupId>commons-io</groupId>
139+
<artifactId>commons-io</artifactId>
140+
<version>2.0.1</version>
141+
</dependency>
142+
-->
143+
144+
<!-- Jackson JSON Processor
145+
<dependency>
146+
<groupId>org.codehaus.jackson</groupId>
147+
<artifactId>jackson-mapper-asl</artifactId>
148+
<version>1.8.1</version>
149+
</dependency>
150+
-->
151+
152+
<!-- Rome Atom+RSS
153+
<dependency>
154+
<groupId>rome</groupId>
155+
<artifactId>rome</artifactId>
156+
<version>1.0</version>
157+
</dependency>
158+
-->
159+
160+
<!-- Test -->
161+
<dependency>
162+
<groupId>junit</groupId>
163+
<artifactId>junit</artifactId>
164+
<version>4.8</version>
165+
<scope>test</scope>
166+
</dependency>
167+
</dependencies>
168+
169+
<repositories>
170+
<repository>
171+
<id>spring-maven-snapshot</id>
172+
<name>Springframework Maven Snapshot Repository</name>
173+
<url>http://repo.springsource.org/snapshot</url>
174+
<snapshots>
175+
<enabled>true</enabled>
176+
</snapshots>
177+
</repository>
178+
</repositories>
179+
180+
<build>
181+
<plugins>
182+
<plugin>
183+
<artifactId>maven-compiler-plugin</artifactId>
184+
<configuration>
185+
<source>${java-version}</source>
186+
<target>${java-version}</target>
187+
</configuration>
188+
</plugin>
189+
<plugin>
190+
<groupId>org.apache.maven.plugins</groupId>
191+
<artifactId>maven-dependency-plugin</artifactId>
192+
<executions>
193+
<execution>
194+
<id>install</id>
195+
<phase>install</phase>
196+
<goals>
197+
<goal>sources</goal>
198+
</goals>
199+
</execution>
200+
</executions>
201+
</plugin>
202+
<plugin>
203+
<groupId>org.apache.maven.plugins</groupId>
204+
<artifactId>maven-eclipse-plugin</artifactId>
205+
<version>2.8</version>
206+
<configuration>
207+
<downloadSources>true</downloadSources>
208+
<downloadJavadocs>false</downloadJavadocs>
209+
<wtpversion>2.0</wtpversion>
210+
</configuration>
211+
</plugin>
212+
<plugin>
213+
<artifactId>maven-surefire-plugin</artifactId>
214+
<configuration>
215+
<includes>
216+
<include>**/*Tests.java</include>
217+
</includes>
218+
<excludes>
219+
<exclude>**/*Abstract*.java</exclude>
220+
</excludes>
221+
</configuration>
222+
</plugin>
223+
</plugins>
224+
</build>
225+
226+
</project>
227+

SPR-0000-war-java/src/main/java/org/springframework/issues/.gitignore

Whitespace-only changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.springframework.issues.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.ComponentScan;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
7+
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
8+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
9+
import org.springframework.web.servlet.view.InternalResourceViewResolver;
10+
11+
@EnableWebMvc
12+
@ComponentScan(basePackages="org.springframework.issues")
13+
@Configuration
14+
public class WebConfig extends WebMvcConfigurerAdapter {
15+
16+
@Override
17+
public void addViewControllers(ViewControllerRegistry registry) {
18+
registry.addViewController("/").setViewName("home");
19+
}
20+
21+
@Bean
22+
public InternalResourceViewResolver viewResolver() {
23+
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
24+
viewResolver.setPrefix("/WEB-INF/views/");
25+
viewResolver.setSuffix(".jsp");
26+
return viewResolver;
27+
}
28+
29+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
log4j.rootCategory=INFO, stdout
2+
3+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5+
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
6+
7+
log4j.category.org.springframework.web=DEBUG
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
2+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3+
<html>
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6+
<title>Home</title>
7+
</head>
8+
<body>
9+
<h1>Home</h1>
10+
</body>
11+
</html>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
5+
6+
<context-param>
7+
<param-name>contextClass</param-name>
8+
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
9+
</context-param>
10+
11+
<context-param>
12+
<param-name>contextConfigLocation</param-name>
13+
<param-value>org.springframework.issues.config</param-value>
14+
</context-param>
15+
16+
<listener>
17+
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
18+
</listener>
19+
20+
<servlet>
21+
<servlet-name>appServlet</servlet-name>
22+
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
23+
<init-param>
24+
<param-name>contextConfigLocation</param-name>
25+
<param-value></param-value>
26+
</init-param>
27+
<load-on-startup>1</load-on-startup>
28+
</servlet>
29+
30+
<servlet-mapping>
31+
<servlet-name>appServlet</servlet-name>
32+
<url-pattern>/</url-pattern>
33+
</servlet-mapping>
34+
35+
<!-- Disables Servlet Container welcome file handling. Needed for compatibility
36+
with Servlet 3.0 and Tomcat 7.0 -->
37+
<welcome-file-list>
38+
<welcome-file></welcome-file>
39+
</welcome-file-list>
40+
41+
</web-app>

SPR-0000-war-java/src/test/java/org/springframework/issues/.gitignore

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
log4j.rootCategory=INFO, stdout
2+
3+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5+
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
6+
7+
log4j.category.org.springframework.web=DEBUG

0 commit comments

Comments
 (0)