assembly依赖
<build>
<plugins>
<!--执行命令打包 mvn clean assembly:assembly -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<!--打包后有两个jar包,一个是没有包含依赖的,一个是包含所有依赖的,包含所有依赖的jar包名称格式为:xxx-jar-with-dependencies.jar-->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<!--程序入口-->
<manifest>
<mainClass>com.example.App</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
logback.xml依赖、配置及使用参考下面的连接
https://blog.csdn.net/qq_17303159/article/details/111995174
示例代码:
package com.example;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
public static void main(String[] args) {
LOGGER.info("app started");
}
}
在项目目录允许以下命令打包:
mvn clean assembly:assembly
启动项目:
java -jar maven-runnable-jar-1.0-SNAPSHOT-jar-with-dependencies.jar
项目结构
参考链接:
https://www.cnblogs.com/guazi/p/6789703.html