Spring多模块项目运行类

huangapple go评论68阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年8月18日 16:42:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/63464934.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定