java maven项目不会导入插件

6qqygrtg  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(560)

我在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>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题