小编Tom*_*ton的帖子

Spring Boot + Thymeleaf的@WebAppConfiguration和@ContextConfiguration

给定一个Spring Boot + Thymeleaf Web应用程序(这与Spring项目的gs- consume -rest"初始"代码树几乎相同):

??? pom.xml
??? src
    ??? main
    ?   ??? java
    ?   ?   ??? hello
    ?   ?       ??? Application.java
    ?   ?       ??? Config.java
    ?   ?       ??? Controller.java
    ?   ??? resources
    ?       ??? templates
    ?           ??? index.html
    ??? test
        ??? java
            ??? hello
                ??? ControllerTest.java
Run Code Online (Sandbox Code Playgroud)

......"Hello World!"让用户受到了满意的欢迎!在http://localhost:8080/,但Spring的"上下文"的连接似乎不适用于集成测试(ControllerTest.java):

java.lang.AssertionError: Status 
Expected :200
Actual   :404
Run Code Online (Sandbox Code Playgroud)

有什么不对的项目布局,和/或配置的注释在测试?

src/main/webapp/是故意失踪,有喜欢的东西一起web.xmlWEB-INF/.这里的目标是使用最小配置,通过集成测试来测试驱动应用程序的视图和控制器的开发.

血腥细节如下.提前抱歉"文字墙".


的pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.1.RELEASE</version> …
Run Code Online (Sandbox Code Playgroud)

java spring integration-testing thymeleaf spring-boot

8
推荐指数
1
解决办法
2万
查看次数