Spring Boot without the web server

后端 未结 16 791
眼角桃花
眼角桃花 2020-11-29 16:50

I have a simple Spring Boot application that gets messages from a JMS queue and saves some data to a log file, but does not need a web server. Is there any way of starting S

相关标签:
16条回答
  • 2020-11-29 17:15

    Similar to @nayun oh answer above, but for older versions of Spring, use this code:

    SpringApplication application = new SpringApplication(DemoApplication.class);
    application.setApplicationContextClass(AnnotationConfigApplicationContext.class);
    application.run(args);
    
    0 讨论(0)
  • 2020-11-29 17:18

    The simplest solution. in your application.properties file. add the following property as mentioned by a previous answer:

    spring.main.web-environment=false

    For version 2.0.0 of Spring boot starter, use the following property :

    spring.main.web-application-type=none

    For documentation on all properties use this link : https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html

    0 讨论(0)
  • 2020-11-29 17:19

    You can use the spring-boot-starter dependency. This will not have the web stuff.

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
    </dependency>
    
    0 讨论(0)
  • 2020-11-29 17:20

    For Spring boot v2.1.3.RELEASE, just add the follow properties into application.propertes:

    spring.main.web-application-type=none
    
    0 讨论(0)
提交回复
热议问题