最近在弄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调试了。
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调试了。