首先在pom文件里引入插件
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.4</version> <configuration> <createDependencyReducedPom>true</createDependencyReducedPom> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>Main.Main</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin>
重构
我们首先要清除缓存 点击clean
然后点击package
会自动打包
等一会 找到target目录下有jar包
如果报错得一行一行去找报错的原因
然后clean 再 package
我们打开命令行
启动jar包