Spring boot 我的spring boot mvc应用程序总是通过显示

Spring boot 我的spring boot mvc应用程序总是通过显示,spring-boot,Spring Boot,请在pom.xml中添加以下依赖项 . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|=====

请在pom.xml中添加以下依赖项

   .   ____          _            __ _ _
  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
 ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
   '  |____| .__|_| |_|_| |_\__, | / / / /
  =========|_|==============|___/=/_/_/_/
  :: Spring Boot ::        (v1.5.6.RELEASE)


 2017-09-03 16:43:53.881  INFO 6584 --- [           main] c.n.SpringBootMvcExampleApplication      : Starting SpringBootMvcExampleApplication on lenovo-PC with PID 6584 (C:\Users\lenovo\Documents\workspace-sts-3.8.4.RELEASE\SpringBootMVCExample\target\classes started by lenovo in C:\Users\lenovo\Documents\workspace-sts-3.8.4.RELEASE\SpringBootMVCExample)
 2017-09-03 16:43:53.896  INFO 6584 --- [           main] c.n.SpringBootMvcExampleApplication      : No active profile set, falling back to default profiles: default
 2017-09-03 16:43:54.218  INFO 6584 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@6e38921c: startup date [Sun Sep 03 16:43:54 IST 2017]; root of context hierarchy
 2017-09-03 16:43:56.213  INFO 6584 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup 2017-09-03 16:43:56.294  INFO 6584 --- [           main] c.n.SpringBootMvcExampleApplication      : Started SpringBootMvcExampleApplication in 3.284 seconds (JVM running for 3.931)
 2017-09-03 16:43:56.297  INFO 6584 --- [       Thread-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@6e38921c: startup date [Sun Sep 03 16:43:54 IST 2017]; root of context hierarchy
 2017-09-03 16:43:56.304  INFO 6584 --- [       Thread-3] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧启动机tomcat
假如

有时由于maven中的jar冲突,spring引导将自动关闭。因此,即使添加了上述依赖项,如果问题仍然存在,请共享
pom.xml

我遇到了同样的问题,我发现我没有告诉Spring要使用的服务器。通过在下面添加maven依赖项,它对我起了作用

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

org.springframework.boot
弹簧启动启动器数据rest
后来我调查发现,上述工件(spring boot starter data rest)中的pom.xml本身引用了以下maven工件,这些工件指示spring添加嵌入式服务器,并在运行当前拥有这个pom.xml的应用程序时使用它

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

org.springframework.boot
弹簧靴起动器
org.springframework.boot
SpringBootStarterWeb
com.fasterxml.jackson.core
杰克逊注释
com.fasterxml.jackson.core
杰克逊数据绑定
org.springframework.data
spring数据rest webmvc
有趣的是,当您进一步查看工件(SpringBootStarterWeb)的POM文件时,您将看到它引用了tomcat服务器的其他工件。下面是您将在pom.xml(SpringBootStarterWeb)中找到的maven工件


org.springframework.boot
弹簧启动机tomcat
注意:由于我的应用程序使用基于Rest的控制器,因此我需要Rest和Json支持。所以下面的maven dependency适合我

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

org.springframework.boot
弹簧启动启动器数据rest
但那个些只想要服务器集成的人,可以使用下面的依赖项,并且它必须工作

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

org.springframework.boot
弹簧靴起动器
org.springframework.boot
SpringBootStarterWeb

我通过删除

弹簧启动机tomcat


依赖性。

我也有这个问题。这是由损坏的存储库造成的。我可以通过在
c:\users\myname\.m2\repository\org\apache
中删除文件夹来解决这个问题
users\myname\.m2\repository\org\apache
,更新项目的maven依赖项对我来说很有用

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

早些时候,我明确地使用了ApacheTomcat,现在我开始学习Spring,它的内部依赖也包括ApacheTomcat。这会导致冲突。

请分享您的主要方法,您使用的是maven吗?添加“org.springframework.boot-spring-boot-starter-web”标记
spring-boot-starter-tomcat
作为
提供的
仅在构建将部署到外部容器的war时才有必要。现在还不清楚,如果没有应用服务器,web应用程序将无法启动,因为它需要servlet容器来启动应用程序。spring引导启动器tomcat依赖项将充当嵌入式tomcat服务器。因此,请包含此内容并重试。
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>