英文:
Spring multimodul project run classes
问题
我有两个已完成的Spring项目,应连接到一个多模块项目。
这在Spring模块中运行良好,我得到一个war文件。
但我不知道如何处理来自两个项目的主运行类。一个和两个都能运行。
在主模块中我只需要一个SpringApplication.run
,还是两个模块中都需要一个更好?
主类:
@SpringBootApplication(scanBasePackages = "com.test.multimodule")
public class App2 extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(App2.class, args);
}
}
英文:
I got two finished spring projects which should be connected to a multimodul-project.
This works fine with the spring modules and I get one war file.
But I don't know what to do with the main run classes from both projects. It works with one and both.
Do I need only one SpringApplication.run
in the main module, or is one in both modules better?
Main class:
@SpringBootApplication(scanBasePackages = "com.test.multimodule")
public class App2 extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(App2.class, args);
}
}
答案1
得分: 0
如果您将应用程序部署为WAR文件,则不需要主函数。只有在您的应用程序中包含Web服务器并将其作为JAR文件从命令行使用 "java -jar yourApp.jar" 启动时才需要主函数。
英文:
If you deploy your application as an WAR file you don't need a main-function. You only need a main function if you include an webserver in your application and start it as a JAR File from the command line with java -jar yourApp.jar.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论