`
wuhuajun
  • 浏览: 92062 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

maven学习

    博客分类:
  • java
 
阅读更多
1.使用archetype生成简单项目架子 
mvn archetype:create -DgroupId=com.fs -DartifactId=test -DpackageName=com.fs.wwy -Dversion=1.0.0
2.mvn install
3.运行 java -cp target/test-1.0-SNAPSHOT.jar com.fs.wwy.test.App
4.运行时候真正的依赖查看  mvn help:effective-pom
6.mvn install 指定生命周期阶段 还可以指定 package test  install会安装到本地仓库中  package只会打包
7.mvn各个生命周期阶段
mvn resources:resources 
mvn compiler:compile 
mvn resources:testResources 
mvn compiler:testCompile 
mvn surefire:test jar:jar  
......................................
mvn install
mvn compile
mvn test
mvn package
mvn site
mvn clean
8.mvn坐标
groupId:artifactId:packaging:version
groupId 公司团体  org.apache com.fs 逆向域名
artifactId 项目名称
9.当一个项目被安装到本地的maven仓库的时候就立刻能被任何其他的项目使用
10.maven自带了一个用来下载maven核心插件和依赖的远程仓库地址 http://repo1.maven.org/maven2
11.
<dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
</dependency>
依赖范围 scope表示在compiler:testCompile时候才会加入classpath  compiler:compile不会
provided范围表示只是在编译的时候需要 不应该捆绑在构件中输出 例如生成war包servelet api不需要打包进去
jar包默认不会捆绑进去。
 
忽略测试:
mvn install -Dmaven.test.failure.ignore=true //忽略失败的用例
mvn install -Dmaven.test.skip=true//跳过测试
 
//打成可执行的jar包
java -jar executble.jar

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifest>
<mainClass>com.fs.wwy.test.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
 
 
exe4j
 
 
 
web应用

mvn archetype:create -DgroupId=com.fs -DartifactId=webapp -DpackageName=com.fs.wwy -Dversion=1.0.0 -DarchetypeArtifactId = maven-archetype-webapp
<plugins>
               <plugin>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>maven-jetty-plugin</artifactId>
                    <version>6.1.6</version>
                    <configuration> 
                       <scanIntervalSeconds>10</scanIntervalSeconds>
                    </configuration>
               </plugin>
          </plugins>
 
mvn jetty:run    在jetty中运行maven项目,默认的端口号8080 
mvn jetty:run -Djetty.port=8082     在jetty中运行maven项目,端口号改成8082 
servlet规范 
geronimo-servlet_2.4_spec 
 
mvn clean install
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics