加入spring-boot-starter-web的话@Configuration路由无法生效

来源:3-1 Spring Boot 构建应用-命令行方式

成佛的小兔几

2018-05-03 11:48

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.0.BUILD-SNAPSHOT</version>
</parent>
<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/libs-snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

之前我没有加入spring-boot-starter-web依赖的时候

https://img.mukewang.com/5aea85e600017c3d08910220.jpg

是可以访问到

https://img.mukewang.com/5aea861c0001fe4608410213.jpg

这个路由的

但是加上

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

这个依赖之后

https://img.mukewang.com/5aea866c00015edf08570282.jpg

就没有@Configuration配置的路由了,也访问不到,只能访问到@RestController

这是版本的问题吗?还是我哪里配置错了

写回答 关注

3回答

  • 慕粉1023215160
    2019-06-12 22:03:29

    同问,为什么Tomcat不行

  • Joe_moke
    2018-12-19 21:17:29

    使用spring-boot-starter-web模块后,默认使用Netty容器吧

  • 木石前盟Cay
    2018-05-18 11:04:52

    使用spring-boot-starter-web模块后,默认使用了tomcat容器

    成佛的小兔几

    问题是Tomcat为什么不行

    2018-05-29 10:21:39

    共 1 条回复 >

Spring Boot 2.0深度实践-初遇Spring Boot

Spring Boot 2.x/Web Flux/多模块化项目实践

75477 学习 · 221 问题

查看课程

相似问题