关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。
想改进这个问题?将问题更新为 on-topic对于堆栈溢出。
5年前关闭。
Improve this question
我刚刚开始学习 Spring-Boot。我使用 gradle 创建了简单的 Spring-Boot Web 应用程序。但我想要一个非 Web 应用程序项目,我可以在其中运行 PSVM 的所有代码,而且我必须删除 tomcat 依赖项。我搜索了它,但没有得到任何例子。
使 Spring Boot 应用程序上下文作为非 Web 应用程序上下文启动需要什么?
最佳答案
Spring Boot 提供了一些示例应用程序:https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples .简单的命令行示例如下:https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-simple
从引用的示例项目中,关键是主类实现CommandLineRunner
- 这是示例项目中的代码:
@SpringBootApplication
public class SampleSimpleApplication implements CommandLineRunner {
// ...
@Override
public void run(String... args) {
// ...
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleSimpleApplication.class, args);
}
}
关于spring - Spring Boot 中的非 Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38741762/