cleanup formatting
This commit is contained in:
parent
4989946b09
commit
38c0a6f9a7
@ -1,262 +1,272 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>spring-thymeleaf</artifactId>
|
<artifactId>spring-thymeleaf</artifactId>
|
||||||
<version>0.1-SNAPSHOT</version>
|
<version>0.1-SNAPSHOT</version>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<properties>
|
|
||||||
<java-version>1.8</java-version>
|
|
||||||
<!-- spring -->
|
|
||||||
<org.springframework-version>4.3.4.RELEASE</org.springframework-version>
|
|
||||||
<springframework-security.version>4.2.0.RELEASE</springframework-security.version>
|
|
||||||
<javax.servlet-version>3.1.0</javax.servlet-version>
|
|
||||||
<!-- logging -->
|
|
||||||
<org.slf4j.version>1.7.21</org.slf4j.version>
|
|
||||||
<logback.version>1.1.7</logback.version>
|
|
||||||
<!-- thymeleaf -->
|
|
||||||
<org.thymeleaf-version>3.0.3.RELEASE</org.thymeleaf-version>
|
|
||||||
<org.thymeleaf.extras-version>3.0.0.RELEASE</org.thymeleaf.extras-version>
|
|
||||||
<thymeleaf-layout-dialect.version>2.1.2</thymeleaf-layout-dialect.version>
|
|
||||||
<!-- validation -->
|
|
||||||
<javax.validation-version>1.1.0.Final</javax.validation-version>
|
|
||||||
<hibernate-validator.version>5.3.3.Final</hibernate-validator.version>
|
|
||||||
<org.hibernate-version>5.2.5.Final</org.hibernate-version>
|
|
||||||
|
|
||||||
<junit.version>4.12</junit.version>
|
<dependencies>
|
||||||
<!-- Maven plugins -->
|
<!-- Spring -->
|
||||||
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
<dependency>
|
||||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
<groupId>org.springframework</groupId>
|
||||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
<artifactId>spring-context</artifactId>
|
||||||
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
<version>${org.springframework-version}</version>
|
||||||
<tomcat7-maven-plugin.version>2.2</tomcat7-maven-plugin.version>
|
<exclusions>
|
||||||
</properties>
|
<!-- Exclude Commons Logging in favor of SLF4j -->
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-webmvc</artifactId>
|
||||||
|
<version>${org.springframework-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependencies>
|
<!-- Spring Security -->
|
||||||
<!-- Spring -->
|
<dependency>
|
||||||
<dependency>
|
<groupId>org.springframework.security</groupId>
|
||||||
<groupId>org.springframework</groupId>
|
<artifactId>spring-security-web</artifactId>
|
||||||
<artifactId>spring-context</artifactId>
|
<version>${springframework-security.version}</version>
|
||||||
<version>${org.springframework-version}</version>
|
</dependency>
|
||||||
<exclusions>
|
<dependency>
|
||||||
<!-- Exclude Commons Logging in favor of SLF4j -->
|
<groupId>org.springframework.security</groupId>
|
||||||
<exclusion>
|
<artifactId>spring-security-config</artifactId>
|
||||||
<groupId>commons-logging</groupId>
|
<version>${springframework-security.version}</version>
|
||||||
<artifactId>commons-logging</artifactId>
|
</dependency>
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-webmvc</artifactId>
|
|
||||||
<version>${org.springframework-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Spring Security -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.security</groupId>
|
|
||||||
<artifactId>spring-security-web</artifactId>
|
|
||||||
<version>${springframework-security.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.security</groupId>
|
|
||||||
<artifactId>spring-security-config</artifactId>
|
|
||||||
<version>${springframework-security.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Thymeleaf -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.thymeleaf</groupId>
|
|
||||||
<artifactId>thymeleaf</artifactId>
|
|
||||||
<version>${org.thymeleaf-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.thymeleaf</groupId>
|
|
||||||
<artifactId>thymeleaf-spring4</artifactId>
|
|
||||||
<version>${org.thymeleaf-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/nz.net.ultraq.thymeleaf/thymeleaf-layout-dialect -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>nz.net.ultraq.thymeleaf</groupId>
|
|
||||||
<artifactId>thymeleaf-layout-dialect</artifactId>
|
|
||||||
<version>${thymeleaf-layout-dialect.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.thymeleaf.extras</groupId>
|
|
||||||
<artifactId>thymeleaf-extras-java8time</artifactId>
|
|
||||||
<version>${org.thymeleaf.extras-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Logging -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-api</artifactId>
|
|
||||||
<version>${org.slf4j.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
<artifactId>logback-classic</artifactId>
|
|
||||||
<version>${logback.version}</version>
|
|
||||||
<!-- <scope>runtime</scope> -->
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>jcl-over-slf4j</artifactId>
|
|
||||||
<version>${org.slf4j.version}</version>
|
|
||||||
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
|
|
||||||
</dependency>
|
|
||||||
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>log4j-over-slf4j</artifactId>
|
|
||||||
<version>${org.slf4j.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Servlet -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
|
||||||
<version>${javax.servlet-version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- Validation -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.validation</groupId>
|
|
||||||
<artifactId>validation-api</artifactId>
|
|
||||||
<version>${javax.validation-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-validator</artifactId>
|
|
||||||
<version>${hibernate-validator.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- test scoped -->
|
|
||||||
|
|
||||||
<dependency>
|
<!-- Thymeleaf -->
|
||||||
<groupId>org.springframework</groupId>
|
<dependency>
|
||||||
<artifactId>spring-test</artifactId>
|
<groupId>org.thymeleaf</groupId>
|
||||||
<version>${org.springframework-version}</version>
|
<artifactId>thymeleaf</artifactId>
|
||||||
<scope>test</scope>
|
<version>${org.thymeleaf-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.thymeleaf</groupId>
|
||||||
|
<artifactId>thymeleaf-spring4</artifactId>
|
||||||
|
<version>${org.thymeleaf-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-test -->
|
<dependency>
|
||||||
<dependency>
|
<groupId>nz.net.ultraq.thymeleaf</groupId>
|
||||||
<groupId>org.springframework.security</groupId>
|
<artifactId>thymeleaf-layout-dialect</artifactId>
|
||||||
<artifactId>spring-security-test</artifactId>
|
<version>${thymeleaf-layout-dialect.version}</version>
|
||||||
<version>${springframework-security.version}</version>
|
</dependency>
|
||||||
<scope>test</scope>
|
<dependency>
|
||||||
</dependency>
|
<groupId>org.thymeleaf.extras</groupId>
|
||||||
|
<artifactId>thymeleaf-extras-java8time</artifactId>
|
||||||
|
<version>${org.thymeleaf.extras-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/junit/junit -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>${junit.version}</version>
|
<version>${org.slf4j.version}</version>
|
||||||
<scope>test</scope>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<version>${logback.version}</version>
|
||||||
|
<!-- <scope>runtime</scope> -->
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>jcl-over-slf4j</artifactId>
|
||||||
|
<version>${org.slf4j.version}</version>
|
||||||
|
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
|
||||||
|
</dependency>
|
||||||
|
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>log4j-over-slf4j</artifactId>
|
||||||
|
<version>${org.slf4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
<!-- Servlet -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<version>${javax.servlet-version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<build>
|
<!-- Validation -->
|
||||||
<plugins>
|
<dependency>
|
||||||
<plugin>
|
<groupId>javax.validation</groupId>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<artifactId>validation-api</artifactId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<version>${javax.validation-version}</version>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
</dependency>
|
||||||
<configuration>
|
<dependency>
|
||||||
<source>${java-version}</source>
|
<groupId>org.hibernate</groupId>
|
||||||
<target>${java-version}</target>
|
<artifactId>hibernate-validator</artifactId>
|
||||||
</configuration>
|
<version>${hibernate-validator.version}</version>
|
||||||
</plugin>
|
</dependency>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
|
||||||
<version>${maven-war-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>${maven-surefire-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/*IntegrationTest.java</exclude>
|
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
|
||||||
</excludes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
<!-- test scoped -->
|
||||||
<groupId>org.codehaus.cargo</groupId>
|
<dependency>
|
||||||
<artifactId>cargo-maven2-plugin</artifactId>
|
<groupId>org.springframework</groupId>
|
||||||
<version>${cargo-maven2-plugin.version}</version>
|
<artifactId>spring-test</artifactId>
|
||||||
<configuration>
|
<version>${org.springframework-version}</version>
|
||||||
<wait>true</wait>
|
<scope>test</scope>
|
||||||
<container>
|
</dependency>
|
||||||
<containerId>jetty8x</containerId>
|
|
||||||
<type>embedded</type>
|
<dependency>
|
||||||
<systemProperties>
|
<groupId>org.springframework.security</groupId>
|
||||||
</systemProperties>
|
<artifactId>spring-security-test</artifactId>
|
||||||
</container>
|
<version>${springframework-security.version}</version>
|
||||||
<configuration>
|
<scope>test</scope>
|
||||||
<properties>
|
</dependency>
|
||||||
<cargo.servlet.port>8082</cargo.servlet.port>
|
|
||||||
</properties>
|
<dependency>
|
||||||
</configuration>
|
<groupId>junit</groupId>
|
||||||
</configuration>
|
<artifactId>junit</artifactId>
|
||||||
</plugin>
|
<version>${junit.version}</version>
|
||||||
<plugin>
|
<scope>test</scope>
|
||||||
<groupId>org.apache.tomcat.maven</groupId>
|
</dependency>
|
||||||
<artifactId>tomcat7-maven-plugin</artifactId>
|
|
||||||
<version>${tomcat7-maven-plugin.version}</version>
|
</dependencies>
|
||||||
<executions>
|
|
||||||
<execution>
|
<build>
|
||||||
<id>tomcat-run</id>
|
<plugins>
|
||||||
<goals>
|
<plugin>
|
||||||
<goal>exec-war-only</goal>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
</goals>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<phase>package</phase>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<path>/</path>
|
<source>${java-version}</source>
|
||||||
<enableNaming>false</enableNaming>
|
<target>${java-version}</target>
|
||||||
<finalName>webapp.jar</finalName>
|
</configuration>
|
||||||
<charset>utf-8</charset>
|
</plugin>
|
||||||
</configuration>
|
<plugin>
|
||||||
</execution>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
</executions>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
</plugin>
|
<version>${maven-war-plugin.version}</version>
|
||||||
</plugins>
|
<configuration>
|
||||||
</build>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*IntegrationTest.java</exclude>
|
||||||
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.cargo</groupId>
|
||||||
|
<artifactId>cargo-maven2-plugin</artifactId>
|
||||||
|
<version>${cargo-maven2-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<wait>true</wait>
|
||||||
|
<container>
|
||||||
|
<containerId>jetty8x</containerId>
|
||||||
|
<type>embedded</type>
|
||||||
|
<systemProperties>
|
||||||
|
</systemProperties>
|
||||||
|
</container>
|
||||||
|
<configuration>
|
||||||
|
<properties>
|
||||||
|
<cargo.servlet.port>8082</cargo.servlet.port>
|
||||||
|
</properties>
|
||||||
|
</configuration>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.tomcat.maven</groupId>
|
||||||
|
<artifactId>tomcat7-maven-plugin</artifactId>
|
||||||
|
<version>${tomcat7-maven-plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>tomcat-run</id>
|
||||||
|
<goals>
|
||||||
|
<goal>exec-war-only</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>package</phase>
|
||||||
|
<configuration>
|
||||||
|
<path>/</path>
|
||||||
|
<enableNaming>false</enableNaming>
|
||||||
|
<finalName>webapp.jar</finalName>
|
||||||
|
<charset>utf-8</charset>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>integration</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
<includes>
|
||||||
|
<include>**/*IntegrationTest.java</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<systemPropertyVariables>
|
||||||
|
<test.mime>json</test.mime>
|
||||||
|
</systemPropertyVariables>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java-version>1.8</java-version>
|
||||||
|
<!-- spring -->
|
||||||
|
<org.springframework-version>4.3.5.RELEASE</org.springframework-version>
|
||||||
|
<springframework-security.version>4.2.1.RELEASE</springframework-security.version>
|
||||||
|
<javax.servlet-version>3.1.0</javax.servlet-version>
|
||||||
|
|
||||||
|
<!-- logging -->
|
||||||
|
<org.slf4j.version>1.7.21</org.slf4j.version>
|
||||||
|
<logback.version>1.1.7</logback.version>
|
||||||
|
|
||||||
|
<!-- thymeleaf -->
|
||||||
|
<org.thymeleaf-version>3.0.3.RELEASE</org.thymeleaf-version>
|
||||||
|
<org.thymeleaf.extras-version>3.0.0.RELEASE</org.thymeleaf.extras-version>
|
||||||
|
<thymeleaf-layout-dialect.version>2.1.2</thymeleaf-layout-dialect.version>
|
||||||
|
|
||||||
|
<!-- validation -->
|
||||||
|
<javax.validation-version>1.1.0.Final</javax.validation-version>
|
||||||
|
<hibernate-validator.version>5.3.3.Final</hibernate-validator.version>
|
||||||
|
<org.hibernate-version>5.2.5.Final</org.hibernate-version>
|
||||||
|
|
||||||
|
<junit.version>4.12</junit.version>
|
||||||
|
|
||||||
|
<!-- Maven plugins -->
|
||||||
|
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
||||||
|
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||||
|
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||||
|
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
||||||
|
<tomcat7-maven-plugin.version>2.2</tomcat7-maven-plugin.version>
|
||||||
|
|
||||||
|
</properties>
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>integration</id>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>integration-test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>test</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
|
||||||
</excludes>
|
|
||||||
<includes>
|
|
||||||
<include>**/*IntegrationTest.java</include>
|
|
||||||
</includes>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<systemPropertyVariables>
|
|
||||||
<test.mime>json</test.mime>
|
|
||||||
</systemPropertyVariables>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -26,7 +26,6 @@ import com.baeldung.thymeleaf.utils.ArrayUtil;
|
|||||||
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
||||||
import nz.net.ultraq.thymeleaf.decorators.strategies.GroupingStrategy;
|
import nz.net.ultraq.thymeleaf.decorators.strategies.GroupingStrategy;
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@ComponentScan({ "com.baeldung.thymeleaf" })
|
@ComponentScan({ "com.baeldung.thymeleaf" })
|
||||||
@ -36,23 +35,23 @@ import nz.net.ultraq.thymeleaf.decorators.strategies.GroupingStrategy;
|
|||||||
*/
|
*/
|
||||||
public class WebMVCConfig extends WebMvcConfigurerAdapter implements ApplicationContextAware {
|
public class WebMVCConfig extends WebMvcConfigurerAdapter implements ApplicationContextAware {
|
||||||
|
|
||||||
private ApplicationContext applicationContext;
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ViewResolver htmlViewResolver() {
|
public ViewResolver htmlViewResolver() {
|
||||||
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
||||||
resolver.setTemplateEngine(templateEngine(htmlTemplateResolver()));
|
resolver.setTemplateEngine(templateEngine(htmlTemplateResolver()));
|
||||||
resolver.setContentType("text/html");
|
resolver.setContentType("text/html");
|
||||||
resolver.setCharacterEncoding("UTF-8");
|
resolver.setCharacterEncoding("UTF-8");
|
||||||
resolver.setViewNames(ArrayUtil.array("*.html"));
|
resolver.setViewNames(ArrayUtil.array("*.html"));
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ViewResolver javascriptViewResolver() {
|
public ViewResolver javascriptViewResolver() {
|
||||||
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
||||||
resolver.setTemplateEngine(templateEngine(javascriptTemplateResolver()));
|
resolver.setTemplateEngine(templateEngine(javascriptTemplateResolver()));
|
||||||
@ -62,7 +61,7 @@ public class WebMVCConfig extends WebMvcConfigurerAdapter implements Application
|
|||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ViewResolver plainViewResolver() {
|
public ViewResolver plainViewResolver() {
|
||||||
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
||||||
resolver.setTemplateEngine(templateEngine(plainTemplateResolver()));
|
resolver.setTemplateEngine(templateEngine(plainTemplateResolver()));
|
||||||
@ -72,7 +71,7 @@ public class WebMVCConfig extends WebMvcConfigurerAdapter implements Application
|
|||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TemplateEngine templateEngine(ITemplateResolver templateResolver) {
|
private TemplateEngine templateEngine(ITemplateResolver templateResolver) {
|
||||||
SpringTemplateEngine engine = new SpringTemplateEngine();
|
SpringTemplateEngine engine = new SpringTemplateEngine();
|
||||||
engine.addDialect(new LayoutDialect(new GroupingStrategy()));
|
engine.addDialect(new LayoutDialect(new GroupingStrategy()));
|
||||||
engine.addDialect(new Java8TimeDialect());
|
engine.addDialect(new Java8TimeDialect());
|
||||||
@ -107,22 +106,22 @@ public class WebMVCConfig extends WebMvcConfigurerAdapter implements Application
|
|||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Description("Spring Message Resolver")
|
@Description("Spring Message Resolver")
|
||||||
public ResourceBundleMessageSource messageSource() {
|
public ResourceBundleMessageSource messageSource() {
|
||||||
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
|
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
|
||||||
messageSource.setBasename("messages");
|
messageSource.setBasename("messages");
|
||||||
return messageSource;
|
return messageSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
registry.addResourceHandler("/resources/**").addResourceLocations("/WEB-INF/resources/");
|
registry.addResourceHandler("/resources/**").addResourceLocations("/WEB-INF/resources/");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Description("Custom Conversion Service")
|
@Description("Custom Conversion Service")
|
||||||
public void addFormatters(FormatterRegistry registry) {
|
public void addFormatters(FormatterRegistry registry) {
|
||||||
registry.addFormatter(new NameFormatter());
|
registry.addFormatter(new NameFormatter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,7 @@ public class WebMVCSecurity extends WebSecurityConfigurerAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(final HttpSecurity http) throws Exception {
|
protected void configure(final HttpSecurity http) throws Exception {
|
||||||
http
|
http.authorizeRequests().anyRequest().authenticated().and().httpBasic();
|
||||||
.authorizeRequests()
|
|
||||||
.anyRequest()
|
|
||||||
.authenticated()
|
|
||||||
.and()
|
|
||||||
.httpBasic()
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,13 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||||||
@Controller
|
@Controller
|
||||||
public class DatesController {
|
public class DatesController {
|
||||||
|
|
||||||
@RequestMapping(value = "/dates", method = RequestMethod.GET)
|
@RequestMapping(value = "/dates", method = RequestMethod.GET)
|
||||||
public String getInfo(Model model) {
|
public String getInfo(Model model) {
|
||||||
model.addAttribute("standardDate", new Date());
|
model.addAttribute("standardDate", new Date());
|
||||||
model.addAttribute("localDateTime", LocalDateTime.now());
|
model.addAttribute("localDateTime", LocalDateTime.now());
|
||||||
model.addAttribute("localDate", LocalDate.now());
|
model.addAttribute("localDate", LocalDate.now());
|
||||||
model.addAttribute("timestamp", Instant.now());
|
model.addAttribute("timestamp", Instant.now());
|
||||||
return "dates.html";
|
return "dates.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,17 +17,17 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||||||
@Controller
|
@Controller
|
||||||
public class ExpressionUtilityObjectsController {
|
public class ExpressionUtilityObjectsController {
|
||||||
|
|
||||||
@RequestMapping(value = "/objects", method = RequestMethod.GET)
|
@RequestMapping(value = "/objects", method = RequestMethod.GET)
|
||||||
public String getDates(Model model) {
|
public String getDates(Model model) {
|
||||||
model.addAttribute("date", new Date());
|
model.addAttribute("date", new Date());
|
||||||
model.addAttribute("calendar", Calendar.getInstance());
|
model.addAttribute("calendar", Calendar.getInstance());
|
||||||
model.addAttribute("num", Math.random() * 10);
|
model.addAttribute("num", Math.random() * 10);
|
||||||
model.addAttribute("string", "new text");
|
model.addAttribute("string", "new text");
|
||||||
model.addAttribute("emptyString", "");
|
model.addAttribute("emptyString", "");
|
||||||
model.addAttribute("nullString", null);
|
model.addAttribute("nullString", null);
|
||||||
model.addAttribute("array", new int[] { 1, 3, 4, 5 });
|
model.addAttribute("array", new int[] { 1, 3, 4, 5 });
|
||||||
model.addAttribute("set", new HashSet<Integer>(Arrays.asList(1, 3, 8)));
|
model.addAttribute("set", new HashSet<Integer>(Arrays.asList(1, 3, 8)));
|
||||||
return "objects.html";
|
return "objects.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,23 +11,23 @@ import com.baeldung.thymeleaf.utils.StudentUtils;
|
|||||||
@Controller
|
@Controller
|
||||||
public class InliningController {
|
public class InliningController {
|
||||||
|
|
||||||
@RequestMapping(value = "/html", method = RequestMethod.GET)
|
@RequestMapping(value = "/html", method = RequestMethod.GET)
|
||||||
public String getExampleHTML(Model model) {
|
public String getExampleHTML(Model model) {
|
||||||
model.addAttribute("title", "Baeldung");
|
model.addAttribute("title", "Baeldung");
|
||||||
model.addAttribute("description", "<strong>Thymeleaf</strong> tutorial");
|
model.addAttribute("description", "<strong>Thymeleaf</strong> tutorial");
|
||||||
return "inliningExample.html";
|
return "inliningExample.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/js", method = RequestMethod.GET)
|
@RequestMapping(value = "/js", method = RequestMethod.GET)
|
||||||
public String getExampleJS(Model model) {
|
public String getExampleJS(Model model) {
|
||||||
model.addAttribute("students", StudentUtils.buildStudents());
|
model.addAttribute("students", StudentUtils.buildStudents());
|
||||||
return "studentCheck.js";
|
return "studentCheck.js";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/plain", method = RequestMethod.GET)
|
@RequestMapping(value = "/plain", method = RequestMethod.GET)
|
||||||
public String getExamplePlain(Model model) {
|
public String getExamplePlain(Model model) {
|
||||||
model.addAttribute("username", SecurityContextHolder.getContext().getAuthentication().getName());
|
model.addAttribute("username", SecurityContextHolder.getContext().getAuthentication().getName());
|
||||||
model.addAttribute("students", StudentUtils.buildStudents());
|
model.addAttribute("students", StudentUtils.buildStudents());
|
||||||
return "studentsList.txt";
|
return "studentsList.txt";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||||||
@Controller
|
@Controller
|
||||||
public class LayoutDialectController {
|
public class LayoutDialectController {
|
||||||
|
|
||||||
@RequestMapping(value = "/layout", method = RequestMethod.GET)
|
@RequestMapping(value = "/layout", method = RequestMethod.GET)
|
||||||
public String getNewPage(Model model) {
|
public String getNewPage(Model model) {
|
||||||
return "content.html";
|
return "content.html";
|
||||||
}
|
}
|
||||||
|
@ -21,30 +21,30 @@ import com.baeldung.thymeleaf.utils.StudentUtils;
|
|||||||
@Controller
|
@Controller
|
||||||
public class StudentController {
|
public class StudentController {
|
||||||
|
|
||||||
@RequestMapping(value = "/saveStudent", method = RequestMethod.POST)
|
@RequestMapping(value = "/saveStudent", method = RequestMethod.POST)
|
||||||
public String saveStudent(@Valid @ModelAttribute Student student, BindingResult errors, Model model) {
|
public String saveStudent(@Valid @ModelAttribute Student student, BindingResult errors, Model model) {
|
||||||
if (!errors.hasErrors()) {
|
if (!errors.hasErrors()) {
|
||||||
// get mock objects
|
// get mock objects
|
||||||
List<Student> students = StudentUtils.buildStudents();
|
List<Student> students = StudentUtils.buildStudents();
|
||||||
// add current student
|
// add current student
|
||||||
students.add(student);
|
students.add(student);
|
||||||
model.addAttribute("students", students);
|
model.addAttribute("students", students);
|
||||||
}
|
}
|
||||||
return ((errors.hasErrors()) ? "addStudent.html" : "listStudents.html");
|
return ((errors.hasErrors()) ? "addStudent.html" : "listStudents.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/addStudent", method = RequestMethod.GET)
|
@RequestMapping(value = "/addStudent", method = RequestMethod.GET)
|
||||||
public String addStudent(Model model) {
|
public String addStudent(Model model) {
|
||||||
model.addAttribute("student", new Student());
|
model.addAttribute("student", new Student());
|
||||||
return "addStudent.html";
|
return "addStudent.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/listStudents", method = RequestMethod.GET)
|
@RequestMapping(value = "/listStudents", method = RequestMethod.GET)
|
||||||
public String listStudent(Model model) {
|
public String listStudent(Model model) {
|
||||||
|
|
||||||
model.addAttribute("students", StudentUtils.buildStudents());
|
model.addAttribute("students", StudentUtils.buildStudents());
|
||||||
|
|
||||||
return "listStudents.html";
|
return "listStudents.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package com.baeldung.thymeleaf.utils;
|
|||||||
|
|
||||||
public class ArrayUtil {
|
public class ArrayUtil {
|
||||||
|
|
||||||
public static String[] array(String... args) {
|
public static String[] array(String... args) {
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,28 +7,28 @@ import com.baeldung.thymeleaf.model.Student;
|
|||||||
|
|
||||||
public class StudentUtils {
|
public class StudentUtils {
|
||||||
|
|
||||||
private static List<Student> students = new ArrayList<Student>();
|
private static List<Student> students = new ArrayList<Student>();
|
||||||
|
|
||||||
public static List<Student> buildStudents() {
|
public static List<Student> buildStudents() {
|
||||||
if (students.isEmpty()){
|
if (students.isEmpty()) {
|
||||||
Student student1 = new Student();
|
Student student1 = new Student();
|
||||||
student1.setId(1001);
|
student1.setId(1001);
|
||||||
student1.setName("John Smith");
|
student1.setName("John Smith");
|
||||||
student1.setGender('M');
|
student1.setGender('M');
|
||||||
student1.setPercentage(Float.valueOf("80.45"));
|
student1.setPercentage(Float.valueOf("80.45"));
|
||||||
|
|
||||||
students.add(student1);
|
students.add(student1);
|
||||||
|
|
||||||
Student student2 = new Student();
|
Student student2 = new Student();
|
||||||
student2.setId(1002);
|
student2.setId(1002);
|
||||||
student2.setName("Jane Williams");
|
student2.setName("Jane Williams");
|
||||||
student2.setGender('F');
|
student2.setGender('F');
|
||||||
student2.setPercentage(Float.valueOf("60.25"));
|
student2.setPercentage(Float.valueOf("60.25"));
|
||||||
|
|
||||||
students.add(student2);
|
students.add(student2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return students;
|
return students;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,35 +31,34 @@ import com.baeldung.thymeleaf.config.WebMVCSecurity;
|
|||||||
@ContextConfiguration(classes = { WebApp.class, WebMVCConfig.class, WebMVCSecurity.class, InitSecurity.class })
|
@ContextConfiguration(classes = { WebApp.class, WebMVCConfig.class, WebMVCSecurity.class, InitSecurity.class })
|
||||||
public class ExpressionUtilityObjectsControllerIntegrationTest {
|
public class ExpressionUtilityObjectsControllerIntegrationTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
WebApplicationContext wac;
|
WebApplicationContext wac;
|
||||||
@Autowired
|
|
||||||
MockHttpSession session;
|
|
||||||
|
|
||||||
private MockMvc mockMvc;
|
@Autowired
|
||||||
|
MockHttpSession session;
|
||||||
|
|
||||||
@Autowired
|
private MockMvc mockMvc;
|
||||||
private Filter springSecurityFilterChain;
|
|
||||||
|
|
||||||
protected RequestPostProcessor testUser() {
|
@Autowired
|
||||||
return user("user1").password("user1Pass").roles("USER");
|
private Filter springSecurityFilterChain;
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
protected RequestPostProcessor testUser() {
|
||||||
public void setup() {
|
return user("user1").password("user1Pass").roles("USER");
|
||||||
mockMvc = MockMvcBuilders.webAppContextSetup(wac).addFilters(springSecurityFilterChain).build();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Before
|
||||||
public void testGetObjects() throws Exception {
|
public void setup() {
|
||||||
mockMvc.perform(get("/objects").with(testUser()).with(csrf())).andExpect(status().isOk())
|
mockMvc = MockMvcBuilders.webAppContextSetup(wac).addFilters(springSecurityFilterChain).build();
|
||||||
.andExpect(view().name("objects.html"));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDates() throws Exception {
|
public void testGetObjects() throws Exception {
|
||||||
mockMvc.perform(get("/dates").with(testUser()).with(csrf())).andExpect(status().isOk())
|
mockMvc.perform(get("/objects").with(testUser()).with(csrf())).andExpect(status().isOk()).andExpect(view().name("objects.html"));
|
||||||
.andExpect(view().name("dates.html"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
|
public void testDates() throws Exception {
|
||||||
|
mockMvc.perform(get("/dates").with(testUser()).with(csrf())).andExpect(status().isOk()).andExpect(view().name("dates.html"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import com.baeldung.thymeleaf.config.WebMVCSecurity;
|
|||||||
@ContextConfiguration(classes = { WebApp.class, WebMVCConfig.class, WebMVCSecurity.class, InitSecurity.class })
|
@ContextConfiguration(classes = { WebApp.class, WebMVCConfig.class, WebMVCSecurity.class, InitSecurity.class })
|
||||||
public class LayoutDialectControllerIntegrationTest {
|
public class LayoutDialectControllerIntegrationTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
WebApplicationContext wac;
|
WebApplicationContext wac;
|
||||||
@Autowired
|
@Autowired
|
||||||
MockHttpSession session;
|
MockHttpSession session;
|
||||||
@ -50,9 +50,9 @@ public class LayoutDialectControllerIntegrationTest {
|
|||||||
mockMvc = MockMvcBuilders.webAppContextSetup(wac).addFilters(springSecurityFilterChain).build();
|
mockMvc = MockMvcBuilders.webAppContextSetup(wac).addFilters(springSecurityFilterChain).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDates() throws Exception{
|
public void testGetDates() throws Exception {
|
||||||
mockMvc.perform(get("/layout").with(testUser()).with(csrf())).andExpect(status().isOk()).andExpect(view().name("content.html"));
|
mockMvc.perform(get("/layout").with(testUser()).with(csrf())).andExpect(status().isOk()).andExpect(view().name("content.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user