我在 intelliJ 社区版中有一个 Maven 项目,我正在尝试将所有内容打包到我可以执行的 jar 文件中。我一直在关注在线教程,并尝试向 pom.xml 文件添加几个插件。 但是它们都以红色显示,并显示以下错误消息:
Plugin 'org.apache.maven.plugins:maven-shade-plugin:' not found
Plugin 'maven-assembly-plugin:' not found
Plugin 'org.apache.maven.plugins:maven-compiler-plugin:' not found
我尝试过使缓存失效和重新启动缓存。我在 Maven 设置中启用了使用插件注册表选项。我也试过多次重新加载 Maven 项目,但没有成功。 有针对这个的解决方法吗?或任何其他方式我可以从项目创建一个可执行的 jar。
仅供参考,如果重要的话,我也在使用 Mac。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer implementation=
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>Your_main_class_here</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>ServiceCreate</finalName>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<mainClass>com.svt.optimoo.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>