maven用于项目构建和管理。包含创建Project、编译、测试、打包、发布

100 阅读1分钟

maven用于项目构建和管理。包含创建Project、编译、测试、打包、发布。

1. Eclipse集成MAVEN

  • 下载maven工具包,解压到某个目录
  • 在eclipse配置maven路径和settings.xml
    window菜单下的preference
    这里写图片描述
    这里写图片描述
    利用eclipse右键创建maven project,点击project右键执行编译、测试、打包菜单

2. Eclipse集成MAVEN

  • jar maven.aliyun.com/nexus/ 阿里云服务器的jar包仓库
    这里写图片描述
  • 在这个配置文件中写入配置
    <
  • project xmlns=”maven.apache.org/POM/4.0.0” xmlns:xsi=”www.w3.org/2001/XMLSch… xsi:schemaLocation=”maven.apache.org/POM/4.0.0 maven.apache.org/xsd/maven-4…“>
  • <modelVersion>4.0.0</modelVersion>//版本号
              <groupId>cn.xdl</groupId>//项目名
              <artifactId>ssh_01</artifactId>//工程名
              <version>0.0.1-SNAPSHOT</version>
              <packaging>war</packaging>//打包成什么格式的
              <!--设置 java源文件编码 -->
            <properties>
    
            <project.build.sourceEncoding>
    
                  UTF-8
            </project.build.sourceEncoding>
        </properties>
          <!-- jar包从仓库中导入 -->
          <!-- http://maven.aliyun.com/nexus/ -->
          <dependencies>
          <dependency>
    
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.12</version>
          </dependency>
          <dependency>
    
          <groupId>Javax.servlet</groupId>
          <artifactId>servlet-api</artifactId>
          <version>3.0-alpha-1</version>
          </dependency>
          </dependencies>
    
        <!-- 指定编译版本和编码 -->
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
            </plugins>
            <!-- 指定编译版本和编码 -->
            <defaultGoal>compile</defaultGoal>
        </build>        </project>*
    
  • 每次修改完配置文件需要更新
    这里写图片描述