我有一个Maven项目,它在src文件夹的一个包中有2个主电源(MyTestApp_A和MyTestApp_B).
如果我打开它们并单击运行按钮,我可以在Eclipse中运行这些"main"类.但是,Eclipse有问题,因此我实际上需要使用Maven在命令行上运行这两个类.
我之前从未使用过Maven,但在寻求帮助并进行一些研究后,我明白我必须更改pom.xml文件.
因此,我已成功更改了我的pom.xml文件,以使用以下命令运行其中一个应用程序mvn exec:java -Dexec.mainClass="servers.MyTestApp_B":
<plugins>
<!-- Allows the example to be run via 'mvn compile exec:java' -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>servers.MyTestApp_A</mainClass>
<includePluginDependencies>false</includePluginDependencies>
</configuration>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
很高兴能够运行MyTestApp_A,我尝试添加另一个配置部件来运行MyTestApp_B:
<plugins>
<!-- Allows the example to be run via 'mvn compile exec:java' -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>servers.MyTestApp_A</mainClass>
<includePluginDependencies>false</includePluginDependencies>
</configuration>
<configuration>
<mainClass>servers.MyTestApp_B</mainClass>
<includePluginDependencies>false</includePluginDependencies>
</configuration>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
但是,此文件格式不正确.显然我不允许<configuration>在同一个pom.xml文件中有2个标签.
那么,我如何使用Maven执行MyTestApp_A和MyTestApp_B?如何配置pom.xml文件?
学习Spring Boot作为一些C/C++守护进程的替代品.我的目标是将一个项目编译成一个jar/war.然后使用多个shell脚本只需通过命令行启动我想要的那个.我正在使用Eclipse Kepler来开发和测试各个Spring Boot应用程序,并发现了一些不需要的行为.在同一个包中有4个Spring Boot应用程序类,如果我使用Eclipse启动配置启动其中任何一个,则所有4个启动都在同一个Spring Boot中启动.我怀疑因为它们都有@SpringBootApplication注释,并且启动它会导致Spring Boot"扫描"当前的包和子包.
我的问题是,有没有办法在同一个包中安装多个Spring Boot应用程序?我是否只使用一个@SpringBootApplication创建一个ControllerApplication并传入我想要启动的守护进程名称并从那里开始?还是其他一些选择?或者我是否需要为每个守护进程创建一个单独的项目?tia,adym