学习笔记--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
<profile>
  <id>jdk-1.7</id>
   
  <activation>
     <activeByDefault>true</activeByDefault>
     <jdk>1.7</jdk>
  </activation>
       
  <properties>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
    <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
  </properties>
</profile>
方法二:在pom.xml的<plugins>中添加如下代码,修改maven默认的JRE编译版本,1.7代表JRE编译的版本
<plugin>    
    <groupId>org.apache.maven.plugins</groupId>    
    <artifactId>maven-compiler-plugin</artifactId>    
    <configuration>
        <source>1.7</source>    
        <target>1.7</target>    
    </configuration>
<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:\xxxx\WebRoot" 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>
posted @   KioLuo  阅读(119)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示