Maven搭建简单的SS项目

今天使用MyEclipse将一个Spring+Struts+c3p0的项目修改为了Maven项目,何其的艰辛啊。 

环境简介:

1.MyEclipse10

2.Maven Eclipse Plugin

操作步骤:

1.创建一个Maven Project.

Maven搭建简单的SS项目

2.在Catalog中选择Internal。在Filter里面输入web。选择,Artifact Id为maven-archetype-webapp的选项。

Maven搭建简单的SS项目

3.

输入Group ID和 Artifact ID

Group ID一般写大项目名称,Artifact ID是子项目名称。

点击finish完成项目创建。

4.需要添加Java EE的lib,在项目中单击右键选择Build Path-->Config Build Path,在Libraries的Tab中,选择Add Library,选择MyEclipse Libraries,选中Java EE 6 Libraries。

5.配置pom.xml

<dependencies>

	<!-- C3P0 -->
	<dependency>
		<groupId>com.mchange</groupId>
		<artifactId>c3p0</artifactId>
		<version>0.9.2-pre5</version>
	</dependency>

	<!-- MySQL jdbc -->
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<version>5.1.21</version>
	</dependency>

	<!-- Struts -->
	<dependency>
		<groupId>org.apache.struts</groupId>
		<artifactId>struts2-core</artifactId>
		<version>2.3.4.1</version>
	</dependency>
	<dependency>
		<groupId>org.apache.struts</groupId>
		<artifactId>struts2-spring-plugin</artifactId>
		<version>2.3.4.1</version>
	</dependency>

	<!-- Spring -->
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-aop</artifactId>
		<version>3.0.5.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-asm</artifactId>
		<version>3.0.5.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-context</artifactId>
		<version>3.0.5.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-core</artifactId>
		<version>3.0.5.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-jdbc</artifactId>
		<version>3.0.5.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-web</artifactId>
		<version>3.0.5.RELEASE</version>
	</dependency>

	<!-- POI -->
	<dependency>
		<groupId>org.apache.poi</groupId>
		<artifactId>poi</artifactId>
		<version>3.8</version>
	</dependency>

	<!-- Log 4j -->
	<dependency>
		<groupId>log4j</groupId>
		<artifactId>log4j</artifactId>
		<version>1.2.17</version>
	</dependency>

	<!-- junit -->
	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>4.10</version>
	</dependency>
</dependencies>


遇到问题:

1.问题:Tomcat在MyEclipse中启动报错: Error waiting for multi-thread deployment of directories to completehostConfig.deploy

解决:在MyEclipse中,Window-->MyEclipse-->Server-->Tomcat-->Tomcat7-->JDK,改为自己安装的JDK即可。

或者修改JDK运行参数,添加-Xms1024m -Xmx1024m -XX:MaxNewSize=256m -XX:MaxPermSize=256m。

2.

问题:ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component

<filter-name>struts2</filter-name>
    <url-pattern>/*.do</url-pattern>

解决:web.xml配置的拦截路径错误。

<filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>

3.

问题:Error configuring application listener of class com.sun.faces.config.ConfigureListener

<!--Java(TM) EE 6 Specification APIs -->
    <dependency>
        <groupId>javax</groupId>
	<artifactId>javaee-api</artifactId>
	<version>6.0</version>
    </dependency>

解决:javaee-api会引入javax-servlet-api,与服务器中的tomcat的jar包重复,就会不引用。

所以将pom中的dependency删除。在Build Path中添加MyEclipse Libraries--> Java EE 5 Libraries。





你可能感兴趣的:(Maven搭建简单的SS项目)