maven 使用小记1

最近在弄APPFUSE,顺便看了一下maven2,照着例子做了一个
1.apache上下载maven2
2.环境变量增加 M2_HOME,path增加 %M2_HOME%/bin;
3.设置本地资源库,默认在C盘,放到自己的目录,在maven解压目录下的conf/settings.xml
  <localRepository>F:/javatools/appfuse-dependencies-2.0.2/</localRepository>
4.如果有代理服务器,需要设置
  <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net,some.host.com</nonProxyHosts>
    </proxy>     
  参数都比较一目了然的。

接着就可以创建你的新项目了。
mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject 

5.启动mysql,默认用户为root,密码为空。
6.休息一下,弄点成果自己看看 mvn jetty:run-war,启动完就可以访问了,http://localhost:8080/
7.接着就是把项目集成进IDE了,看文档:
  You can develop your application using Eclipse, IDEA or NetBeans. For Eclipse, run mvn install
eclipse:eclipse to generate project files. For IDEA, use mvn idea:idea. Further instructions can be
found in the IDE Reference Guide. 
  按eclipse举例:
  In your project's directory, run mvn eclipse:eclipse. This will generate project files using the
Maven Eclipse Plugin. If you're using a modular archetype, you may need to run mvn install
eclipse:eclipse.
  直接到项目目录敲:mvn eclipse:eclipse

8.怎么让eclipse知道资源库 的目录呢?
  select Window > Preferences. Select the Java > Build Path > Classpath Variables page and set M2_REPO to
equal ~/.m2/repository.    

9.如何调试?我用的是eclipse-jee-ganymede-win32 ,里面已经集成了Eclipse Web Tools Project (WTP)   
修改文件 myproject/.settings/org.eclipse.wst.common.component:
• 删除 <wb-resource deploy-path="/" source-path="src/main/webapp"/>
• 增加 <wb-resource deploy-path="/" source-path="target/myproject-webapp-1.0-SNAPSHOT"/>
• 删除 <wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>

修改文件 myproject/.classpath
• 删除<classpathentry kind="src" path="src/main/resources" excluding="ApplicationResources_zh*.properties ... **/*.java"/>
• 增加<classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.web.container"/>

然后就可以使用TOMCAT调试了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值