使用CommandRunner

@SpringBootApplication
public class CrmApplication implements ApplicationRunner {

    @Autowired
    private HelloService helloService;

    public static void main(String[] args) {
        new SpringApplicationBuilder(CrmApplication.class)
                .web(WebApplicationType.NONE)
                .bannerMode(Banner.Mode.OFF)
                .run(args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println(helloService.getName());
        System.exit(0);
    }
}
@SpringBootApplication
public class NotwebApplication implements CommandLineRunner {

    @Autowired
    private HelloService helloService;

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(NotwebApplication.class);
        app.setBannerMode(Banner.Mode.OFF);
        app.run();
    }

    @Override
    public void run(String... args) throws Exception {
        System.out.println(helloService.getName());
        System.exit(0);
    }
}
// spring.main.web-application-type=none

相关文章:

  • 2021-08-20
  • 2021-11-01
  • 2021-05-30
  • 2022-02-23
猜你喜欢
  • 2022-12-23
  • 2021-12-30
  • 2021-12-16
  • 2021-11-05
  • 2021-07-07
  • 2021-04-21
相关资源
相似解决方案