Idea导入github的maven工程报错的方法

内容纲要
  1. 使用idea打开pom文件,并作为项目打开
  2. 这时候点击锤子按钮进行编译,会报各种奇奇怪怪的错误,一招搞定
    选中maven的这个按钮:Execution Maven Goal:
    file
    执行命令:mvn idea:idea 执行完成后再点击idea的build命令,显示成功,打开看对应的java文件,也没有任何编译错误。就是这么舒服
    file

如果执行命令的时候jar包无法下载,或者瞎子啊速度慢,需要使用阿里云的镜像仓库。
修改idea的maven配置指定settings.xml地址。
file
setting.xml内容如下:需要自行配置<localRepository>/Users/ximouzhao/.m2/repository</localRepository>的地址为对应的你的机器的地址喔

<?xml version="1.0" encoding="UTF-8"?>
<settings
    xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <!--本地仓库。该值表示构建系统本地仓库的路径。其默认值为${user.home}/.m2/repository。  -->
    <localRepository>/Users/ximouzhao/.m2/repository</localRepository>
    <!--配置服务端的一些设置。如果局域网内部有nexus,需要管理项目jar包可配置 -->
    <servers></servers>
    <!--为仓库列表配置的下载镜像列表-->
    <mirrors>
        <!--给定仓库的下载镜像-->
        <mirror>
            <id>aliyun</id>
            <mirrorOf>central</mirrorOf>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        </mirror>
    </mirrors>
    <!-- 仓库配置 -->
    <profiles>
        <!--根据环境参数来调整的构件的配置 -->
        <profile>
            <!--该配置的唯一标识符 -->
            <id>lovecto_profile</id>
            <!-- 远程仓库列表 -->
            <repositories>
                <repository>
                    <id>aliyun</id>
                    <name>aliyun</name>
                    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </repository>
            </repositories>
            <!-- 配置插件下载的仓库列表-->
            <pluginRepositories>
                <pluginRepository>
                    <id>thirdparty_repository</id>
                    <name>thirdparty_repository</name>
                    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <!-- 激活所使用的配置-->
    <activeProfiles>
        <activeProfile>lovecto_profile</activeProfile>
    </activeProfiles>
</settings>
Idea导入github的maven工程报错的方法

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

滚动到顶部