使用Maven命令打包:在命令行中,你可以直接使用Maven的打包命令mvn package,而无需额外指定mainClass,因为Maven会读取pom.xml中的配置。然而,如果你想要验证或者确保使用了正确的配置,可以通过mvn compile来编译项目,然后使用java -jar命令结合Java的-cp或-classpath选项来运行你的jar文件,但这并不是打包时直接指定mainC...
将TestCase类,都包含到一个Suite中 @RunWith(Suite.class) @SuiteClasses({ TestCase1.class, TestCase2.class }) public class TestSuite { } 1. 2. 3. 4. 带main函数的 java类 public class TestRunner { public static void main(String[] args) { Result result = JUnitCore.runClasses(TestSuite.cl...
要指定Maven打包时的main函数,需要在pom.xml文件中配置maven-compiler-plugin插件,并指定mainClass属性。 在build节点下添加以下代码: <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</sour...
pom.xml中 build中 plugins中 增加plugin <plugin><artifactId>maven-assembly-plugin</artifactId><configuration><appendAssemblyId>false</appendAssemblyId><descriptorRefs><descriptorRef>jar-with-dependencies</descriptorRef></descriptorRefs><archive><manifest><mainClass>hg.swing.active.mq.AppMain</mainClass>...
在springboot 项目中,除了启动类的主函数 mainclass,如果还出现其他的 main 方法,本地运行是没有任何问题,但是在打包 package 时,就会报错,说 repackage 时,在项目中有多个候选的主方法。这时候,我们就需要在 maven 的 pom.xml 文件中指定打包时的 mainCla...
-- MainClass in mainfest make a executable jar --><archive><manifest><mainClass>Main函数类</mainClass></manifest></archive></configuration><executions><execution><id>make-assembly</id><!-- bind to the packaging phase --><phase>package</phase><goals><goal>single</goal></goals></...
1.org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEASE:repackage failed: Unable to find main class 2.找不到符号 Unable to find main class 问题原因 如果使用SpringBoot打包插件如下 <build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin<...
例如:com.example.MainClass1,com.example.MainClass2步骤3:创建主函数(Main method)或指定方法如果您还没有创建主函数或指定方法,请在您的Java项目中创建一个包含Main方法的类。确保该类具有以下签名:public static void main(String[] args)步骤4:生成可执行jar包完成上述步骤后,您可以使用以下命令生成可执行jar...
<artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>microservice.javaapp.histclient.HelloWorldMaven</mainClass> </manifest> </archive> </configuration> </plugin> </...
eclipse --->project --->clean...选项将工程中的.class文件删除,同时重新编译工程,类似于jbuild中的rebuild。 见下图Clean结束之后会自动进行Build 问题二 找不到主类或无法加载主类的问题 是因为.java文件不在项目的src路径内,也就是说源代码未被eclipse编译,字节码不存在无法运行了,在项目名上右键 -> Builde...