`
sunxboy
  • 浏览: 2828437 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

Maven基础

阅读更多

下载Maven安装文件。

定义环境变量M2_HOME到path中。
在DOS下输入mvn -version查看是否安装正确。

 

1.修改本地仓库存储路径

2.x
<settings> 
  <localRepository>/path/to/local/repo </localRepository>

</settings>

1.x

在用户HOME目录下创建build.properties文件:maven.home.local=D:/MavenRepo/.maven


在项目的project.properties里设置:maven.repo.local=D:/MavenRepo/.maven

 

2. 配置 Jetty 插件

<project> 
  [...] 
  <build> 
    <finalName>simple-webapp</finalName> 
    <plugins> 
      <plugin> 
        <groupId>org.mortbay.jetty</groupId> 
        <artifactId>maven-jetty-plugin</artifactId> 
  </plugin> 
    </plugins> 
  </build> 
  [...] 
</project>

 运行Jetty: mvn jetty:run

 

3.添加 Servlet 2.4依赖

<project> 
  [...] 
  <dependencies> 
    [...] 
    <dependency> 
      <groupId>org.apache.geronimo.specs</groupId> 
      <artifactId>geronimo-servlet_2.4_spec</artifactId> 
      <version>1.1.1</version> 
      <scope>provided</scope> 
    </dependency> 
  </dependencies> 
  [...] 
</project> 

 

4.编译项目

mvn compile 

 mvn clean install 

 之后,运行jetty

 

5.添加 JSP 2.0 依赖

<project> 
  [...] 
  <dependencies> 
    [...] 
    <dependency> 
      <groupId>org.apache.geronimo.specs</groupId> 
      <artifactId>geronimo-jsp_2.0_spec</artifactId> 
      <version>1.1</version> 
      <scope>provided</scope> 
    </dependency> 
  </dependencies> 
  [...] 
</project> 

 

6.添加包到本地库

mvn install:install-file -Dfile=jta-1.0.1B.jar -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar

 

7.maven骨干工程的构建

// Creating a simple java application
mvn archetype:create -DgroupId=[group id] -DartifactId=[artifact id]
// Creating a webapp
mvn archetype:create -DgroupId=[group id] -DartifactId=[artifact id] 
                              -DarchetypeArtifactId=maven-archetype-webapp
// Creating a site
mvn archetype:create -DgroupId=[group id] -DartifactId=[artifact id] 
                              -DarchetypeArtifactId=maven-archetype-site-simple
// Creating a mojo
mvn archetype:create -DgroupId=[group id] -DartifactId=[artifact id] 
                              -DarchetypeArtifactId=maven-archetype-mojo
// Creating a portlet
mvn archetype:create -DgroupId=[group id] -DartifactId=[artifact id] 
                              -DarchetypeArtifactId=maven-archetype-portlet
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics