Eclipse搭建Maven项目并上传SVN备份

Posted Hello_World_CFF

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Eclipse搭建Maven项目并上传SVN备份相关的知识,希望对你有一定的参考价值。

本文出自:http://www.cnblogs.com/2186009311CFF/p/7226127.html

背景:近段时间在学着Java,想着用Java做BS的项目。但是项目一遇到问题又要重做,故想起了用SVN做备份。

硬件条件:电脑是windows的64位系统。

一、建项目的总体思路是:

前期:

a.安装JDK,配置JAVA环境变量(Eclipse基于JAVA环境,所以必须安装JDK)

  从Oracle官网下载适合系统的JDK:http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html#javasejdk

  安装并配置Java环境变量

  若安装成功,打开命令提示符,输入“java -version”,类似如图所示,则说明安装成功

b.workspace:UTF-8

  选择Windows下的Preferences,如图:

 

  出现下图,输入workspace,选择workspace,把GBK改为UTF-8,选择Apply,OK,具体如下图:

c.安装配置meven +本地仓库

  去maven官网下载maven:

  配置maven环境变量

  Eclipse配置maven:

  Eclipse配置本地仓库前,请确认本地仓库的setting.xml内容的下面位置是您本地仓库实际所在位置:(若无setting.xml文件则在maven的解压文件中拷贝一份到本地仓库文件下,改成实际本地仓库的位置,再在Eclipse里配置)

  本地仓库就是所有jar包的集合。

  Eclipse配置本地仓库如下:

搭建Maven项目步骤:

1.project
parent
pom
pom管理版本号

 

 

 

pom文件如下所示:

 

用以下文件此模块的pom.xml文件:

  1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  3     <modelVersion>4.0.0</modelVersion>
  4     <groupId>cn.e3mall</groupId>
  5     <artifactId>e3-parent</artifactId>
  6     <version>0.0.1-SNAPSHOT</version>
  7     <packaging>pom</packaging>
  8     <!-- 集中定义依赖版本号 -->
  9     <properties>
 10         <junit.version>4.12</junit.version>
 11         <spring.version>4.2.4.RELEASE</spring.version>
 12         <mybatis.version>3.2.8</mybatis.version>
 13         <mybatis.spring.version>1.2.2</mybatis.spring.version>
 14         <mybatis.paginator.version>1.2.15</mybatis.paginator.version>
 15         <mysql.version>5.1.32</mysql.version>
 16         <slf4j.version>1.6.4</slf4j.version>
 17         <jackson.version>2.4.2</jackson.version>
 18         <druid.version>1.0.9</druid.version>
 19         <httpclient.version>4.3.5</httpclient.version>
 20         <jstl.version>1.2</jstl.version>
 21         <servlet-api.version>2.5</servlet-api.version>
 22         <jsp-api.version>2.0</jsp-api.version>
 23         <joda-time.version>2.5</joda-time.version>
 24         <commons-lang3.version>3.3.2</commons-lang3.version>
 25         <commons-io.version>1.3.2</commons-io.version>
 26         <commons-net.version>3.3</commons-net.version>
 27         <pagehelper.version>3.4.2-fix</pagehelper.version>
 28         <jsqlparser.version>0.9.1</jsqlparser.version>
 29         <commons-fileupload.version>1.3.1</commons-fileupload.version>
 30         <jedis.version>2.7.2</jedis.version>
 31         <solrj.version>4.10.3</solrj.version>
 32         <dubbo.version>2.5.3</dubbo.version>
 33         <zookeeper.version>3.4.7</zookeeper.version>
 34         <zkclient.version>0.1</zkclient.version>
 35         <activemq.version>5.11.2</activemq.version>
 36         <freemarker.version>2.3.23</freemarker.version>
 37         <quartz.version>2.2.2</quartz.version>
 38     </properties>
 39     <dependencyManagement>
 40         <dependencies>
 41             <!-- 时间操作组件 -->
 42             <dependency>
 43                 <groupId>joda-time</groupId>
 44                 <artifactId>joda-time</artifactId>
 45                 <version>${joda-time.version}</version>
 46             </dependency>
 47             <!-- Apache工具组件 -->
 48             <dependency>
 49                 <groupId>org.apache.commons</groupId>
 50                 <artifactId>commons-lang3</artifactId>
 51                 <version>${commons-lang3.version}</version>
 52             </dependency>
 53             <dependency>
 54                 <groupId>org.apache.commons</groupId>
 55                 <artifactId>commons-io</artifactId>
 56                 <version>${commons-io.version}</version>
 57             </dependency>
 58             <dependency>
 59                 <groupId>commons-net</groupId>
 60                 <artifactId>commons-net</artifactId>
 61                 <version>${commons-net.version}</version>
 62             </dependency>
 63             <!-- Jackson Json处理工具包 -->
 64             <dependency>
 65                 <groupId>com.fasterxml.jackson.core</groupId>
 66                 <artifactId>jackson-databind</artifactId>
 67                 <version>${jackson.version}</version>
 68             </dependency>
 69             <!-- httpclient -->
 70             <dependency>
 71                 <groupId>org.apache.httpcomponents</groupId>
 72                 <artifactId>httpclient</artifactId>
 73                 <version>${httpclient.version}</version>
 74             </dependency>
 75             <!-- quartz任务调度框架 -->
 76             <dependency>
 77                 <groupId>org.quartz-scheduler</groupId>
 78                 <artifactId>quartz</artifactId>
 79                 <version>${quartz.version}</version>
 80             </dependency>
 81             <!-- 单元测试 -->
 82             <dependency>
 83                 <groupId>junit</groupId>
 84                 <artifactId>junit</artifactId>
 85                 <version>${junit.version}</version>
 86                 <scope>test</scope>
 87             </dependency>
 88             <!-- 日志处理 -->
 89             <dependency>
 90                 <groupId>org.slf4j</groupId>
 91                 <artifactId>slf4j-log4j12</artifactId>
 92                 <version>${slf4j.version}</version>
 93             </dependency>
 94             <!-- Mybatis -->
 95             <dependency>
 96                 <groupId>org.mybatis</groupId>
 97                 <artifactId>mybatis</artifactId>
 98                 <version>${mybatis.version}</version>
 99             </dependency>
100             <dependency>
101                 <groupId>org.mybatis</groupId>
102                 <artifactId>mybatis-spring</artifactId>
103                 <version>${mybatis.spring.version}</version>
104             </dependency>
105             <dependency>
106                 <groupId>com.github.miemiedev</groupId>
107                 <artifactId>mybatis-paginator</artifactId>
108                 <version>${mybatis.paginator.version}</version>
109             </dependency>
110             <dependency>
111                 <groupId>com.github.pagehelper</groupId>
112                 <artifactId>pagehelper</artifactId>
113                 <version>${pagehelper.version}</version>
114             </dependency>
115             <!-- MySql -->
116             <dependency>
117                 <groupId>mysql</groupId>
118                 <artifactId>mysql-connector-java</artifactId>
119                 <version>${mysql.version}</version>
120             </dependency>
121             <!-- 连接池 -->
122             <dependency>
123                 <groupId>com.alibaba</groupId>
124                 <artifactId>druid</artifactId>
125                 <version>${druid.version}</version>
126             </dependency>
127             <!-- Spring -->
128             <dependency>
129                 <groupId>org.springframework</groupId>
130                 <artifactId>spring-context</artifactId>
131                 <version>${spring.version}</version>
132             </dependency>
133             <dependency>
134                 <groupId>org.springframework</groupId>
135                 <artifactId>spring-beans</artifactId>
136                 <version>${spring.version}</version>
137             </dependency>
138             <dependency>
139                 <groupId>org.springframework</groupId>
140                 <artifactId>spring-webmvc</artifactId>
141                 <version>${spring.version}</version>
142             </dependency>
143             <dependency>
144                 <groupId>org.springframework</groupId>
145                 <artifactId>spring-jdbc</artifactId>
146                 <version>${spring.version}</version>
147             </dependency>
148             <dependency>
149                 <groupId>org.springframework</groupId>
150                 <artifactId>spring-aspects</artifactId>
151                 <version>${spring.version}</version>
152             </dependency>
153             <dependency>
154                 <groupId>org.springframework</groupId>
155                 <artifactId>spring-jms</artifactId>
156                 <version>${spring.version}</version>
157             </dependency>
158             <dependency>
159                 <groupId>org.springframework</groupId>
160                 <artifactId>spring-context-support</artifactId>
161                 <version>${spring.version}</version>
162             </dependency>
163             <!-- JSP相关 -->
164             <dependency>
165                 <groupId>jstl</groupId>
166                 <artifactId>jstl</artifactId>
167                 <version>${jstl.version}</version>
168             </dependency>
169             <dependency>
170                 <groupId>javax.servlet</groupId>
171                 <artifactId>servlet-api</artifactId>
172                 <version>${servlet-api.version}</version>
173                 <scope>provided</scope>
174             </dependency>
175             <dependency>
176                 <groupId>javax.servlet</groupId>
177                 <artifactId>jsp-api</artifactId>
178                 <version>${jsp-api.version}</version>
179                 <scope>provided</scope>
180             </dependency>
181             <!-- 文件上传组件 -->
182             <dependency>
183                 <groupId>commons-fileupload</groupId>
184                 <artifactId>commons-fileupload</artifactId>
185                 <version>${commons-fileupload.version}</version>
186             </dependency>
187             <!-- Redis客户端 -->
188             <dependency>
189                 <groupId>redis.clients</groupId>
190                 <artifactId>jedis</artifactId>
191                 <version>${jedis.version}</version>
192             </dependency>
193             <!-- solr客户端 -->
194             <dependency>
195                 <groupId>org.apache.solr</groupId>
196                 <artifactId>solr-solrj</artifactId>
197                 <version>${solrj.version}</version>
198             </dependency>
199             <!-- dubbo相关 -->
200             <dependency>
201                 <groupId>com.alibaba</groupId>
202                 <artifactId>dubbo</artifactId>
203                 <version>${dubbo.version}</version>
204             </dependency>
205             <dependency>
206                 <groupId>org.apache.zookeeper</groupId>
207                 <artifactId>zookeeper</artifactId>
208                 <version>${zookeeper.version}</version>
209             </dependency>
210             <dependency>
211                 <groupId>com.github.sgroschupf</groupId>
212                 <artifactId>zkclient</artifactId>
213                 <version>${zkclient.version}</version>
214             </dependency>
215             <dependency>
216                 <groupId>org.apache.activemq</groupId>
217                 <artifactId>activemq-all</artifactId>
218                 <version>${activemq.version}</version>
219             </dependency>
220             <dependency>
221                 <groupId>org.freemarker</groupId>
222                 <artifactId>freemarker</artifactId>
223                 <version>${freemarker.version}</version>
224             </dependency>
225 
226         </dependencies>
227     </dependencyManagement>
228 
229     <build>
230         <finalName>${project.artifactId}</finalName>
231         <plugins>
232             <!-- 资源文件拷贝插件 -->
233             <plugin>
234                 <groupId>org.apache.maven.plugins</groupId>
235                 <artifactId>maven-resources-plugin</artifactId>
236                 <version>2.7</version>
237                 <configuration>
238                     <encoding>UTF-8</encoding>
239                 </configuration>
240             </plugin>
241             <!-- java编译插件 -->
242             <plugin>
243                 <groupId>org.apache.maven.plugins</groupId>
244                 <artifactId>maven-compiler-plugin</artifactId>
245                 <version>3.2</version>
246                 <configuration>
247                     <source>1.7</source>
248                     <target>1.7</target>
249                     <encoding>UTF-8</encoding>
250                 </configuration>
251             </plugin>
252         </plugins>
253         <pluginManagement>
254             <plugins>
255                 <!-- 配置Tomcat插件 -->
256                 <plugin>
257                     <groupId>org.apache.tomcat.maven</groupId>
258                     <artifactId>tomcat7-maven-plugin</artifactId>
259                     <version>2.2</version>
260                 </plugin>
261             </plugins>
262         </pluginManagement>
263     </build>
264 </project>

  如下所示:

2.project
common
jar
继承parent
pom包括所有的jar包依赖项,黄色可删除

 

 

 

 

pom文件用以下文件替代:

 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 3     <modelVersion>4.0.0</modelVersion>
 4     <parent>
 5         <groupId>cn.e3mall</groupId>
 6         <artifactId>e3-parent</artifactId>
 7         <version>0.0.1-SNAPSHOT</version>
 8     </parent>
 9     <groupId>cn.e3mall</groupId>
10     <artifactId>e3-common</artifactId>
11     <version>0.0.1-SNAPSHOT</version>
12     <dependencies>
13         <!-- 时间操作组件 -->
14         <dependency>
15             <groupId>joda-time</groupId>
16             <artifactId>joda-time</artifactId>
17         </dependency>
18         <!-- Apache工具组件 -->
19         <dependency>
20             <groupId>org.apache.commons</groupId>
21             <artifactId>commons-lang3</artifactId>
22         </dependency>
23         <dependency>
24             <groupId>org.apache.commons</groupId>
25             <artifactId>commons-io</artifactId>
26         </dependency>
27         <dependency>
28             <groupId>commons-net</groupId>
29             <artifactId>commons-net</artifactId>
30         </dependency>
31         <!-- Jackson Json处理工具包 -->
32         <dependency>
33             <groupId>com.fasterxml.jackson.core</groupId>
34             <artifactId>jackson-databind</artifactId>
35         </dependency>
36         <!-- httpclient -->
37         <dependency>
38             <groupId>org.apache.httpcomponents</groupId>
39             <artifactId>httpclient</artifactId>
40         </dependency>
41         <!-- quartz任务调度框架 -->
42         <dependency>
43             <groupId>org.quartz-scheduler</groupId>
44             <artifactId>quartz</artifactId>
45         </dependency>
46         <!-- 单元测试 -->
47         <dependency>
48             <groupId>junit</groupId>
49             <artifactId>junit</artifactId>
50             <scope>test</scope>
51         </dependency>
52         <!-- 日志处理 -->
53         <dependency>
54             <groupId>org.slf4j</groupId>
55             <artifactId>slf4j-log4j12</artifactId>
56         </dependency>
57     </dependencies>
58 </project>

 


3.project
manager
pom
继承parent
pom 依赖common

 

 

 

用以下文件替换此模块的pom.xml文件:

 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 3     <modelVersion>4.0.0</modelVersion>
 4     <parent>
 5         <groupId>cn.e3mall</groupId>
 6         <artifactId>e3-parent</artifactId>
 7         <version>0.0.1-SNAPSHOT</version>
 8     </parent>
 9     <groupId>cn.e3mall</groupId>
10     <artifactId>e3-manager</artifactId>
11     <version>0.0.1-SNAPSHOT</version>
12     <packaging>pom</packaging>
13     <dependencies>
14         <dependency>
15             <groupId>cn.e3mall</groupId>
16             <artifactId>e3-common</artifactId>
17             <version>0.0.1-SNAPSHOT</version>
18         </dependency>
19     </dependencies>
20     <modules>
21         <module>e3-manager-dao</module>
22         <module>e3-manager-pojo</module>
23         <module>e3-manager-interface</module>
24         <module>e3-manager-service</module>
25         <module>e3-manager-web</module>
26     </modules>
27     
40 </project>

 

4.moudle
manager-pojo
jar

 

 

 

5.moudle
manager-dao
jar
pom 依赖pojo、mybatis、MySql、连接池

 

 

 

 

用以下文件替换此模块的pom.xml文件:

 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 3     <modelVersion>4.0.0</modelVersion>
 4     <parent>
 5         <groupId>cn.e3mall</groupId>
 6         <artifactId>e3-manager</artifactId>
 7         <version>0.0.1-SNAPSHOT</version>
 8     </parent>
 9     <artifactId>e3-manager-dao</artifactId>
10     <dependencies>
11         <dependency>
12             <groupId>cn.e3mall</groupId>
13             <artifactId>e3-manager-pojo</artifactId>
14             <version>0.0.1-SNAPSHOT</version>
15         </dependency>
16         <!-- 添加对mybatis的依赖 -->
17         <dependency>
18             <groupId>org.mybatis</groupId>
19             <artifactId>mybatis</artifactId>
20         </dependency>
21         <dependency>
22             <groupId>org.mybatis</groupId>
23             <artifactId>mybatis-spring</artifactId>
24         </dependency>
25         <dependency>
26             <groupId>com.github.miemiedev</groupId>
27             <artifactId>mybatis-paginator</artifactId>
28         </dependency>
29         <dependency>
30             <groupId>com.github.pagehelper</groupId>
31             <artifactId>pagehelper</artifactId>
32         </dependency>
33         <!-- MySql -->
34         <dependency>
35             <groupId>mysql</groupId>
36             <artifactId>mysql-connector-java</artifactId>
37         </dependency>
38         <!-- 连接池 -->
39         <dependency>
40             <groupId>com.alibaba</groupId>
41             <artifactId>druid</artifactId>
42         </dependency>
43     </dependencies>
44 </project>

6.moudle
manager-interface
jar
pom 依赖pojo

 

 

 

 用以下文件替换此模块的pom.xml文件:

 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 3     <modelVersion>4.0.0</modelVersion>
 4     <parent>
 5         <groupId>cn.e3mall</groupId>
 6         <artifactId>e3-manager</artifactId>
 7         <version>0.0.1-SNAPSHOT</version>
 8     </parent>
 9     <artifactId>e3-manager-interface</artifactId>
10     <dependencies>
11         <dependency>
12             <groupId>cn.e3mall</groupId>
13             <artifactId>e3-manager-pojo</artifactId>
14             <version>0.0.1-SNAPSHOT</version>
15         </dependency>
16     </dependencies>
17 </project>

 

7.moudle
manager-service
enter(jar)
pom 依赖dao、interface、spring

 

 

 

  用以下文件替换此模块的pom.xml文件:

 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 3     <modelVersion>4.0.0</modelVersion>
 4     <parent>
 5         <groupId>cn.e3mall</groupId>
 6         <artifactId>e3-manager</artifactId>
 7         <version>0.0.1-SNAPSHOT</version>
 8     </parent>
 9     <artifactId>e3-manager-service</artifactId>
10     <dependencies>
11         <dependency>
12             <groupId>cn.e3mall</groupId>
13             <artifactId>e3-manager-dao</artifactId>
14             <version>0.0.1-SNAPSHOT</version>
15         </dependency>
16         <dependency>
17             <groupId>cn.e3mall</groupId>
18             <artifactId>e3-manager-interface</artifactId>
19             <version>0.0.1-SNAPSHOT</version>
20         </dependency>
21         <!-- spring的依赖 -->
22         <!-- Spring -->
23         <dependency>
24             <groupId>org.springframework</groupId>
25             <artifactId>spring-context</artifactId>
26         </dependency>
27         <dependency>
28             <groupId>org.springframework</groupId>
29             <artifactId>spring-beans</artifactId>
30         </dependency>
31         <dependency>
32             <groupId>org.springframework</groupId>
33             <artifactId>spring-webmvc</artifactId>
34         </dependency>
35         <dependency>
36             <groupId>org.springframework</groupId>
37             <artifactId>spring-jdbc</artifactId>
38         </dependency>
39         <dependency>
40             <groupId>org.springframework</groupId>
41             <artifactId>spring-aspects</artifactId>
42         </dependency>
43         <dependency>
44             <groupId>org.springframework</groupId>
45             <artifactId>spring-jms</artifactId>
46         </dependency>
47         <dependency>
48             <groupId>org.springframework</groupId>
49             <artifactId>spring-context-support</artifactId>
50         </dependency>
51     </dependencies>
52 </project>

 

8.moudle
manager-web
war
pom 依赖service、jsp相关
(javaEE Tools--> Generate Deploy Descriptor)war需要补全目录结构src/main/webapp/WEB-INF/web.xml文件

 

 

以上是关于Eclipse搭建Maven项目并上传SVN备份的主要内容,如果未能解决你的问题,请参考以下文章

svn导出一个maven项目到eclipse中后,不显示maven项目标志

eclipse如何从svn上导出maven工程

从零开始学OpenDaylight之四:Maven工具

Eclipse中从svn中检出maven项目

eclipse+maven 在svn下载项目后出现很多的error 如下图.请高手帮忙看下.谢谢

总结:搭建eclipse 插件 maven + svn + sts