java项目,配置maven,编译项目

1、安装maven,例如安装路径 D:\jianing\ToolsInstallation\Java开发工具\apache-maven-2.2.1

2、在环境变量里配置maven路径,(Win7)控制面板->用户账户->更改我的环境变量->系统环境:建立环境变量MAVEN_HOME,赋值:D:\jianing\ToolsInstallation\Java开发工具\apache-maven-2.2.1

3、在文件夹D:\jianing\ToolsInstallation\Java开发工具\apache-maven-2.2.1\conf里设置setting.xml文件的内容,根据maven服务器的信息进行配置,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-releases</name>
          <url>http://artifactory.xxx-develop.com/libs-releases</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshots</name>
          <url>http://artifactory.xxx-develop.com/libs-snapshots</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>plugins-releases</name>
          <url>http://artifactory.xxx-develop.com/plugins-releases</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>plugins-snapshots</name>
          <url>http://artifactory.xxx-develop.com/plugins-snapshots</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

4、在IDEA 里设置setting.xml配置路径,File -> Settings -> Maven ->User settings file: "D:\jianing\ToolsInstallation\Java开发工具\apache-maven-2.2.1\conf\settings.xml"


编译: 右边Maven Projects -> Profiles下面,勾选 artifactory  和 dev-publish, 只需要clean和compile 项目PROJECTname(root)即可。

猜你喜欢

转载自blog.csdn.net/jn1705/article/details/16983489