开发环境:
eclipse WTP 3.4
tomcat 5.5
maven配置
eclipse配置maven:
过程记录:
new project-->Dynamic web project
新建完后,Enable maven(点按右键)
用如下命令新建maven struts2 basic:
mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.seedlife.onlineshop -DartifactId=onlineshop
完成后,进入刚新建项目onlineshop目录下,运行:
mvn appfuse:full-source 注意settings.xml的 <!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ~/.m2/repository <localRepository>/path/to/local/repo</localRepository> --> <localRepository>E:\SKY\appfuse\repository</localRepository> localRepository这里不能有空格,这个好像是ant的造成。
接着把maven项目onlineshop里面的src文件夹下main种test文件夹放到dynamic web project(我的是shop)src里面的,然后更改shop里面的.classpath文件和 .settings/org.eclipse.wst.common.component文件。(红色 代表更改地方)
.classpath:
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src/test/java"/> <classpathentry kind="src" path="src/main/java"/> <classpathentry kind="src" path="src/test/resources"/> <classpathentry kind="src" path="src/main/resources"/> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"> <attributes> <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> </attributes> </classpathentry> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v5.5"/> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> <classpathentry kind="output" path="target/classes"/> </classpath>
org.eclipse.wst.common.component:
<?xml version="1.0" encoding="UTF-8"?> <project-modules id="moduleCoreId" project-version="1.5.0"> <wb-module deploy-name="shop"> <wb-resource deploy-path="/" source-path="/src/main/webapp"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <property name="context-root" value="shop"/> <property name="java-output-path" value="target/classes"/> </wb-module> </project-modules>
再去把Dynamic web project(我的是shop)里面的build和WebContent文件夹删除掉。
最后修改shop的J2EE Module Dependencies:
点右键--Properties---J2EE Module Dependencies----maven Dependencies--Apply--OK