maven

来源:互联网 发布:股票交易模拟软件 编辑:程序博客网 时间:2024/06/03 18:17

1.maven个人配置文件讲解

1.setting.xml文件包含全局设置文件和个人设置文件,全局设置文件为maven安装目录下的文件,个人设置文件一般在一下目录
Unix/Mac OS X - ~/.m2Windows – C:\Documents and Settings\{your-username}\.m2
2.本地仓库存储位置依据< localRepository>指定
<localRepository>D:\JAVAEE\apache-maven-3.3.9\localRepository</localRepository>
3.可以通过< mirrors>标签指定代理
<mirrors>    <mirror>      <id>alimaven</id>      <name>aliyun maven</name>      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>      <mirrorOf>central</mirrorOf>            </mirror>    <!-- mirror     | Specifies a repository mirror site to use instead of a given repository. The repository that     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.     |    <mirror>      <id>mirrorId</id>      <mirrorOf>repositoryId</mirrorOf>      <name>Human Readable Name for this Mirror.</name>      <url>http://my.repository.com/repo/path</url>    </mirror>     --></mirrors>
4.全局配置config文件夹下/localRepository
<profile>      <id>jdk18</id>      <activation>          <activeByDefault>true</activeByDefault>          <jdk>1.8</jdk>      </activation>      <properties>          <maven.compiler.source>1.8</maven.compiler.source>          <maven.compiler.target>1.8</maven.compiler.target>          <maven.compiler.compilerVersion>1.87</maven.compiler.compilerVersion>      </properties>   </profile>

2.maven项目配置文件

1.指定jdk版本
<bulid>    <plugins>        <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-compiler-plugin</artifactId>            <configuration>            <source>1.8</source>            <target>1.8</target>            </configuration>        </plugin>    </plugins></bulid>
2.ssm配置文件模板
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">    <modelVersion>4.0.0</modelVersion>    <groupId>socialPractise</groupId>    <artifactId>social_practise</artifactId>    <packaging>war</packaging>    <version>1.0-SNAPSHOT</version>    <name>social_practise Maven Webapp</name>    <url>http://maven.apache.org</url>    <dependencies>        <!--junit-->        <dependency>            <groupId>junit</groupId>            <artifactId>junit</artifactId>            <version>4.11</version>            <scope>test</scope>        </dependency>        <!--javaee-->        <dependency>            <groupId>javax</groupId>            <artifactId>javaee-api</artifactId>            <version>8.0</version>            <scope>provided</scope>        </dependency>        <!--mail jar-->        <dependency>            <groupId>javax.mail</groupId>            <artifactId>javax.mail-api</artifactId>            <version>1.5.6</version>        </dependency>        <dependency>            <groupId>com.sun.mail</groupId>            <artifactId>javax.mail</artifactId>            <version>1.5.6</version>        </dependency>        <!--springmvc-->        <dependency>            <groupId>org.springframework</groupId>            <artifactId>spring-web</artifactId>            <version>4.3.12.RELEASE</version>        </dependency>        <dependency>            <groupId>org.springframework</groupId>            <artifactId>spring-webmvc</artifactId>            <version>4.3.12.RELEASE</version>        </dependency>        <!--springmvc返回json数据-->        <dependency>            <groupId>com.fasterxml.jackson.core</groupId>            <artifactId>jackson-databind</artifactId>            <version>2.9.0.pr4</version>        </dependency>        <dependency>            <groupId>com.fasterxml.jackson.core</groupId>            <artifactId>jackson-core</artifactId>            <version>2.9.0.pr4</version>        </dependency>        <dependency>            <groupId>com.fasterxml.jackson.core</groupId>            <artifactId>jackson-annotations</artifactId>            <version>2.9.0.pr4</version>        </dependency>        <!--spring-->        <dependency>            <groupId>org.springframework</groupId>            <artifactId>spring-context</artifactId>            <version>4.3.12.RELEASE</version>        </dependency>        <!--spring管理数据源-->        <dependency>            <groupId>org.springframework</groupId>            <artifactId>spring-jdbc</artifactId>            <version>4.3.12.RELEASE</version>        </dependency>        <!--springAOP-->        <dependency>            <groupId>org.aspectj</groupId>            <artifactId>aspectjrt</artifactId>            <version>1.8.11</version>        </dependency>        <dependency>            <groupId>org.aspectj</groupId>            <artifactId>aspectjweaver</artifactId>            <version>1.8.11</version>        </dependency>        <!--mybatis核心包-->        <dependency>            <groupId>org.mybatis</groupId>            <artifactId>mybatis</artifactId>            <version>3.3.1</version>        </dependency>        <!--spring整合mybatis-->        <dependency>            <groupId>org.mybatis</groupId>            <artifactId>mybatis-spring</artifactId>            <version>1.3.1</version>        </dependency>        <!--mysql连接器-->        <dependency>            <groupId>mysql</groupId>            <artifactId>mysql-connector-java</artifactId>            <version>6.0.6</version>        </dependency>        <!--dbcp数据源,用于创建数据库连接池-->        <dependency>            <groupId>org.apache.commons</groupId>            <artifactId>commons-dbcp2</artifactId>            <version>2.1.1</version>        </dependency>        <!--数据库时间问题-->        <dependency>            <groupId>joda-time</groupId>            <artifactId>joda-time</artifactId>            <version>2.3</version>        </dependency>        <!--工具类-->        <dependency>            <groupId>commons-lang</groupId>            <artifactId>commons-lang</artifactId>            <version>2.6</version>        </dependency>    </dependencies>    <build>        <finalName>social_practise</finalName>        <plugins>            <!--mybatis-generator-->            <plugin>                <groupId>org.mybatis.generator</groupId>                <artifactId>mybatis-generator-maven-plugin</artifactId>                <version>1.3.2</version>                <configuration>                    <verbose>true</verbose>                    <overwrite>true</overwrite>                </configuration>            </plugin>            <!--maven-->            <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>

3.maven创建项目并编译

mvn generate:archetype //依据模板创建不同类型的java项目mvn clean package //编译生成war包
原创粉丝点击