学习笔记--maven

//更改镜像库

在<mirrors>元素里面加一个<mirror>配置

<mirror>

    <id>aliyun</id>

    <mirrorOf>centeral</mirrorOf>

    <name>aliyun mirror</name>

    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>

</mirror>


在<profiles>中加一个<profile>配置


<profile>

    <id>aliyun</id>

    <activation>

        <activeByDefault>true</activeByDefault>

    </activation>


    <repositories>

        <repository>

            <id>aliyun</id>

    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>

        </repository>

    </repositories>


    <pluginRepositories>

            <pluginRepository>

                <id>aliyun</id>

        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>

            </pluginRepository>

      </pluginRepositories>

</profile>


//配置默认JDK版本
方法一:
在maven的配置文件settings.xml中的<profiles>标签里添加如下代码,设置默认JRE编译版本为1.7
  1. <profile>
  2. <id>jdk-1.7</id>
  3. <activation>
  4. <activeByDefault>true</activeByDefault>
  5. <jdk>1.7</jdk>
  6. </activation>
  7. <properties>
  8. <maven.compiler.source>1.7</maven.compiler.source>
  9. <maven.compiler.target>1.7</maven.compiler.target>
  10. <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
  11. </properties>
  12. </profile>
方法二:在pom.xml的<plugins>中添加如下代码,修改maven默认的JRE编译版本,1.7代表JRE编译的版本
  1. <plugin>
  2. <groupId>org.apache.maven.plugins</groupId>
  3. <artifactId>maven-compiler-plugin</artifactId>
  4. <configuration>
  5. <source>1.7</source>
  6. <target>1.7</target>
  7. </configuration>
  8. <plugin>

//创建Kitchen项目
mvn archetype:generate -DgroupId=com.netease.restaurant -DartifactId=Kitchen -Dpackage=com.netease -Dversion=1.0.0-SNAPSHOT -DarchetypeArtifactId=maven-archetype-quickstart

//创建Restaurant
mvn archetype:generate -DgroupId=com.netease.restaurant -DartifactId=Restaurant -Dpackage=com.netease -Dversion=1.0.0-SNAPSHOT -DarchetypeArtifactId=maven-archetype-webapp

//maven工程和java工程转换
mvn eclipse:eclipse 
或 
mvn eclipse:myeclipse
eclipse中转换
maven工程转为一般工程:工程右键-->Maven-->Disable Maven Nature转为一般工程
一般工程转为maven工程:工程右键-->Configure-->Convert to maven project

//查看帮助
mvn help:describe -Dplugin=<plugin_name> -Dgoal=<goal> -Ddetail=true
mvn help:help -Ddetail=true

mvn help:describe -Dplugin=war
或者
mvn help:describe -Dplugin=org.apache.maven.plugins:maven-war-plugin
或者

mvn help:describe -DgroupId=org.apache.maven.plugins -DartifactId=maven-war-plugin


//修改tomcat的context path

Tomcat自身可以通过修改配置文件server.xml,在和之间插入如下语句:

<Context path="/xxxx" docBase="F:xxxxWebRoot" debug="0" privileged="true"> </Context>
  • 1

对应maven的tomcat插件弄法如下:

          <!-- tomcat 7 --><plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><version>2.0-SNAPSHOT</version><configuration><path>${context.path}</path><url>http://localhost:8080/manager/text</url><server>tomcat7</server><username>admin</username><password>admin</password></configuration></plugin>
原文地址:https://www.cnblogs.com/kioluo/p/6860490.html