MyEclipse使用总结——将原有的MyEclipse中的项目转成maven项目[转]
时间:2022-04-03 09:42
前面一篇文章中我们了解了
那么如果我们原来有一些项目现在想转成maven项目应该怎么做呢
我收集到了三种思路:
一、新建一个maven项目,把原项目按照新项目的框架移植过去
二、在原项目的框架上进行修改,把项目目录结构修改成maven框架一样 (详见:)
三、不改动原项目目录结构,通过pom.xml文件来配置目录
个人意见,在原项目上做目录结构容易出问题,特别是已经有svn信息时,所以我推荐方案一和三。
本篇先尝试方案一。
我原有一个ipFilter项目,现在已经新建好了maven框架的web项目ipFilterM (x详见:)
ipFilter的目录结构如图:
ipFilterM的目录结构如图:
在pom.xml中添加依赖包的配置
在ipFilter项目中依赖了很多包,如图:
我们要把这些依赖包配置到pom.xml文件中
未配置前pom.xml的内容如下:
[java]
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>ipFilterM</groupId>
- <artifactId>ipFilterM</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>war</packaging>
- <name/>
- <description/>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>bean-validator</artifactId>
- <version>3.0-JBoss-4.0.2</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.annotation</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.ejb</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.enterprise.deploy</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.jms</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.management.j2ee</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>javax.persistence</artifactId>
- <version>2.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.resource</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.security.auth.message</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.security.jacc</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.servlet</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.servlet.jsp</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.servlet.jsp.jstl</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.transaction</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api-osgi</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>jsr311-api</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.web</groupId>
- <artifactId>jstl-impl</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.4.3</version>
- </dependency>
- <dependency>
- <groupId>javax.xml</groupId>
- <artifactId>webservices-api-osgi</artifactId>
- <version>2.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-osgi-bundle</artifactId>
- <version>1.0.1-SP3</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </project>
配置方法详见:
添加一个我们自己的包后,发现ipFilterM项目中自动生成了maven的依赖library,里面就有我们新添加的包
在添加过程中,每点击一次保存,都会自动从中央库下载依赖包,如果项目出现了红色感叹号,则说明 某个包的依赖与已有的依赖冲突或者重复了,删除该依赖保存即可回复正常
有X号但是没有报错信息,则说明 某个包在中央库下载不到,坐标不对,这时候尝试换换版本号可回复正常
依次把ipFilter的依赖包添加完,pom.xml如下:
[java]
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>ipFilterM</groupId>
- <artifactId>ipFilterM</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>war</packaging>
- <name />
- <description />
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>bean-validator</artifactId>
- <version>3.0-JBoss-4.0.2</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.annotation</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.ejb</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.enterprise.deploy</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.jms</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.management.j2ee</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>javax.persistence</artifactId>
- <version>2.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.resource</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.security.auth.message</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.security.jacc</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.servlet</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.servlet.jsp</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.servlet.jsp.jstl</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.transaction</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api-osgi</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>jsr311-api</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.web</groupId>
- <artifactId>jstl-impl</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.4.3</version>
- </dependency>
- <dependency>
- <groupId>javax.xml</groupId>
- <artifactId>webservices-api-osgi</artifactId>
- <version>2.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-osgi-bundle</artifactId>
- <version>1.0.1-SP3</version>
- </dependency>
- <!--我添加的包如下 -->
- <dependency>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>apache-mime4j-core</artifactId>
- <version>0.7.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.ws.commons.axiom</groupId>
- <artifactId>axiom-api</artifactId>
- <version>1.2.13</version>
- </dependency>
- <dependency>
- <groupId>org.apache.ws.commons.axiom</groupId>
- <artifactId>axiom-impl</artifactId>
- <version>1.2.13</version>
- </dependency>
- <dependency>
- <groupId>org.apache.ws.commons.axiom</groupId>
- <artifactId>axiom-dom</artifactId>
- <version>1.2.13</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-adb</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-adb-codegen</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-codegen</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-fastinfoset</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-java2wsdl</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-ant-plugin</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-clustering</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-jibx</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-json</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-kernel</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-mtompolicy</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-saaj</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-soapmonitor-servlet</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-spring</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-http</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-local</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-xmlbeans</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>bcel</groupId>
- <artifactId>bcel</artifactId>
- <version>5.1</version>
- </dependency>
- <dependency>
- <groupId>net.sf.jmatchparser</groupId>
- <artifactId>jMatchParser-icu4j-chardet</artifactId>
- <version>0.1</version>
- </dependency>
- <dependency>
- <groupId>com.github.sebhoss</groupId>
- <artifactId>common-annotations</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- <version>1.8.3</version>
- </dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>1.6</version>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2.1</version>
- </dependency>
- <dependency>
- <groupId>commons-discovery</groupId>
- <artifactId>commons-discovery</artifactId>
- <version>0.4</version>
- </dependency>
- <dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>1.3</version>
- </dependency>
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>3.1</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.6</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.1</version>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>1.6.1</version>
- </dependency>
- <dependency>
- <groupId>net.sf.ezmorph</groupId>
- <artifactId>ezmorph</artifactId>
- <version>1.0.6</version>
- </dependency>
- <dependency>
- <groupId>net.sourceforge.htmlcleaner</groupId>
- <artifactId>htmlcleaner</artifactId>
- <version>2.2</version>
- </dependency>
- <dependency>
- <groupId>org.freemarker</groupId>
- <artifactId>freemarker</artifactId>
- <version>2.3.19</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.2.5</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient-cache</artifactId>
- <version>4.2.5</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- <version>4.2.4</version>
- </dependency>
- <dependency>
- <groupId>gov.nist.math</groupId>
- <artifactId>jama</artifactId>
- <version>1.0.3</version>
- </dependency>
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.11.0.GA</version>
- </dependency>
- <dependency>
- <groupId>net.sf.json-lib</groupId>
- <artifactId>json-lib</artifactId>
- <version>2.3</version>
- <classifier>jdk15</classifier>
- </dependency>
- <dependency>
- <groupId>org.jsoup</groupId>
- <artifactId>jsoup</artifactId>
- <version>1.7.2</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.17</version>
- </dependency>
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-core</artifactId>
- <version>4.3.1</version>
- </dependency>
- <dependency>
- <groupId>org.mongodb</groupId>
- <artifactId>mongo-java-driver</artifactId>
- <version>2.10.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.neethi</groupId>
- <artifactId>neethi</artifactId>
- <version>3.0.2</version>
- </dependency>
- <dependency>
- <groupId>ognl</groupId>
- <artifactId>ognl</artifactId>
- <version>3.0.6</version>
- </dependency>
- <dependency>
- <groupId>org.apache.poi</groupId>
- <artifactId>poi</artifactId>
- <version>3.9</version>
- </dependency>
- <dependency>
- <groupId>org.quartz-scheduler</groupId>
- <artifactId>quartz</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
- <groupId>org.quartz-scheduler</groupId>
- <artifactId>quartz-jobs</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.6.6</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>1.7.5</version>
- </dependency>
- <dependency>