简体   繁体   English

切换spring-boot-starter-jersey的spring-boot-starter-web时的奇怪行为

[英]Odd behavior when switching spring-boot-starter-web for spring-boot-starter-jersey

As per the documentation I'd expect that I can swap spring-boot-starter-web for spring-boot-starter-jetty and all my rest controllers should work as before. 根据文档,我希望可以将spring-boot-starter-web换成spring-boot-starter-jetty,所有其余的控制器都应该像以前一样工作。 Strange enough, after doing this, not a single controller is mapped, not even those from the actuator starter. 奇怪的是,这样做之后,没有映射单个控制器,甚至没有映射执行器启动器的控制器。

Pom below 下面的Pom

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>myproject</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <!-- Inherit defaults from Spring Boot -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.0.RELEASE</version>
    </parent>

    <!-- Add typical dependencies for a web application -->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
    </dependencies>

    <!-- Package as an executable jar -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

I think you have just forgotten to add the jersey starter dependency in your pom file 我认为您只是忘记在pom文件中添加jersey入门依赖项

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 spring-boot-starter-web和spring-boot-starter-web-services以及spring-boot-starter-jersey之间的区别 - Difference between spring-boot-starter-web and spring-boot-starter-web-services and spring-boot-starter-jersey 使用spring-boot-starter-web的Spring Boot无法在Maven中编译 - Spring Boot with spring-boot-starter-web fails to compile in maven spring initializr:spring-boot-starter vs spring-boot-starter-web - spring initializr: spring-boot-starter vs spring-boot-starter-web 在没有 spring-boot-starter-web 的情况下配置 Spring Security AuthenticationManager - Configure Spring Security AuthenticationManager without spring-boot-starter-web @boot注解在Spring Boot中的spring-boot-starter-jersey资源上的用途 - Purpose of @Component annotation on spring-boot-starter-jersey resources in Spring boot 为什么我们需要在spring-boot-starter-jersey项目中为Jersey资源提供@Component spring注释? - Why do we need @Component spring annotation for Jersey resource in spring-boot-starter-jersey project? @CrossOrigin 不适用于 spring-boot-starter-web 2.5.2 - @CrossOrigin not working for spring-boot-starter-web 2.5.2 如何限制 spring-boot-starter-web 中的完整有效负载大小? - How to limit full payload size in spring-boot-starter-web? 结合 ObjectDB 使用 Spring-Boot-Starter-Web - Using Spring-Boot-Starter-Web in combination with ObjectDB spring-boot-starter-tomcat vs spring-boot-starter-web - spring-boot-starter-tomcat vs spring-boot-starter-web
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM