[英]How can I launch the main class lying in a maven module, starting from the project itself?
如果我有一个Maven的文件夹中的一个项目,其中一个包含这应该是启动(并且可以从那里发射)主类,我应该怎么做Eclipse和Maven来启动该上课的时候我选择Run as
- Java Application
从头夹?
编辑:
maven-exec-plugin没有帮助:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>use_annotations.UseAnnotationsLaunch</mainClass>
</configuration>
</execution>
</executions> </plugin>
没有显示任何错误,但是主项目无法启动use_annotations.UseAnnotationsLaunch.main。 我收到“选择不包含主类型”
请注意,Maven编译命令正确调用了maven模块的编译。 这是eclipse和maven模块的问题。
如果我没记错的话,Eclipse和Maven正在使用它们自己的类路径/运行配置,因此您可以使用Eclipse的运行配置,也可以在pom.xml中设置maven-exec-plugin并设置运行配置以调用maven。
如果使用Eclipse的内置“运行”设置了正确的类路径,可能会更舒适,但是如果要编译并在其他计算机上运行它,则使用Maven运行配置将确保正确设置项目。
这是我旧项目的安装程序,既有exec插件,也有jar-with-dependencies(可执行jar)。 请不要介意插件版本...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>my.old.project.package.gui.MainWindow</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>my.old.project.package.gui.MainWindow</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.