如何从多模块专家项目构建可执行jar?
我是专家的初学者,不了解很多东西。我可以构建简单的可执行jar,但是如何将多模块maven项目构建为可执行jar对我来说是神奇的。所以,我有三个项目。父母:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>Test</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>Main</module>
<module>Dep</module>
</modules>
</project>
还有两个子项目:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>Test</artifactId>
<groupId>org.example</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>Main</artifactId>
<dependencies>
<dependency>
<groupId>org.example</groupId>
<artifactId>Dep</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
和:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>Test</artifactId>
<groupId>org.example</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>Dep</artifactId>
</project>
主模块有主类和主方法(lol)
public class Main {
public static void main(String[] args) {
Hello hello = new Hello();
System.out.println(hello.sayHello());
}
}
类 Hello 在 Dep 模块中定义。我应该在我的poms中添加什么来构建可执行jar,从主模块的Main类作为入口点?