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

作者:dayu

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配置本地仓库如下:

技术分享

步骤:

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     <!-- 配置tomcat插件 -->
28     <build>
29         <plugins>
30             <plugin>
31                 <groupId>org.apache.tomcat.maven</groupId>
32                 <artifactId>tomcat7-maven-plugin</artifactId>
33                 <configuration>
34                     <port>8080</port>
35                     <path>/</path>
36                 </configuration>
37             </plugin>
38         </plugins>
39     </build>
40 </project>

4.moudle
manager-pojo
jar

技术分享

技术分享

技术分享

技术分享

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

技术分享

技术分享

技术分享

技术分享


6.moudle
manager-interface
jar
pom 依赖pojo

技术分享

技术分享

技术分享

技术分享

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

技术分享

技术分享

技术分享

技术分享

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

9.配置Tomcat插件
manager的pom配置Tomcat插件

10.parent+common
Run as——>Maven Install
本地仓库的cn/e3mall下就会有该文件了


11.manager-web/src/main/webapp下新建index.jsp
UTF-8

12.manager
Run as——>Maven Build
clean tomcat7:run

二、SVN的使用:

作为一个Java初学者,就这段时间的短浅入门做个记录,以便更多初学者,不足之处请留言。

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

原文地址:http://www.cnblogs.com/2186009311CFF/p/7226127.html