Given the Spring Boot + Thymeleaf web application (this is almost identical to the Spring gs project -consumption-rest "initial" code tree ):
βββ pom.xml βββ src βββ main β βββ java β β βββ hello β β βββ Application.java β β βββ Config.java β β βββ Controller.java β βββ resources β βββ templates β βββ index.html βββ test βββ java βββ hello βββ ControllerTest.java
... user is welcomed just fine with Hello World! at http://localhost:8080/ , but Spring's βcontextβ posting doesn't seem to apply in the integration test ( ControllerTest.java ):
java.lang.AssertionError: Status Expected :200 Actual :404
What happened to the project layout and / or configuration annotations in the test?
src/main/webapp/ intentionally missing along with things like web.xml and WEB-INF/ . The goal here is to use a minimal configuration with an integration test to test the development of the view and application controller.
More details. Sorry for the "text wall" in advance.
pom.xml
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.1.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> </dependencies>
Application.java
package hello;
Controller.java
package hello; @org.springframework.stereotype.Controller public class Controller { }
Config.java
package hello;
ControllerTest.java
package hello;
index.html
<!DOCTYPE html> <html> <head> <title>Hello World!</title> </head> <body> <p>Hello world!</p> </body> </html>
source share