springmvc maven idea 多模块开发(三):建立子模块

传统的多模块方式是建立domain、dao、service等,这种方式是按照软件架构进行分割,现在更多的应该是倾向按照功能来解耦,module前期可以配置成jar,后期也可以建立独有的页面,独立的站点,通过子域名的方式访问,各个功能模块解耦,趋向微服务架构,下面就按照这种方式进行处理

一、建立公共模块

 

 

某块生成完毕后,修改本模块的pom.xml,添加必要的包,由于本模块是继承父模块,所以不需要在引用包上加version了

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 
  3 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5     <parent>
  6         <artifactId>xframe</artifactId>
  7         <groupId>xie.frame</groupId>
  8         <version>1.0-SNAPSHOT</version>
  9     </parent>
 10     <modelVersion>4.0.0</modelVersion>
 11 
 12     <artifactId>xframe-common</artifactId>
 13 
 14     <name>xframe-common</name>
 15     <packaging>jar</packaging>
 16     <properties>
 17         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 18         <maven.compiler.source>1.8</maven.compiler.source>
 19         <maven.compiler.target>1.8</maven.compiler.target>
 20     </properties>
 21 
 22     <dependencies>
 23         <dependency>
 24             <groupId>org.apache.logging.log4j</groupId>
 25             <artifactId>log4j-api</artifactId>
 26         </dependency>
 27         <dependency>
 28             <groupId>junit</groupId>
 29             <artifactId>junit</artifactId>
 30         </dependency>
 31         <dependency>
 32             <groupId>javassist</groupId>
 33             <artifactId>javassist</artifactId>
 34         </dependency>
 35         <dependency>
 36             <groupId>org.springframework</groupId>
 37             <artifactId>spring-core</artifactId>
 38         </dependency>
 39         <dependency>
 40             <groupId>org.springframework</groupId>
 41             <artifactId>spring-beans</artifactId>
 42         </dependency>
 43         <dependency>
 44             <groupId>org.springframework</groupId>
 45             <artifactId>spring-context-support</artifactId>
 46         </dependency>
 47         <dependency>
 48             <groupId>dom4j</groupId>
 49             <artifactId>dom4j</artifactId>
 50         </dependency>
 51         <dependency>
 52             <groupId>com.belerweb</groupId>
 53             <artifactId>pinyin4j</artifactId>
 54         </dependency>
 55         <dependency>
 56             <groupId>commons-collections</groupId>
 57             <artifactId>commons-collections</artifactId>
 58         </dependency>
 59         <dependency>
 60             <groupId>org.apache.ant</groupId>
 61             <artifactId>ant</artifactId>
 62         </dependency>
 63         <dependency>
 64             <groupId>javax.servlet</groupId>
 65             <artifactId>javax.servlet-api</artifactId>
 66             <scope>provided</scope>
 67         </dependency>
 68     </dependencies>
 69 
 70     <build>
 71         <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
 72             <plugins>
 73                 <plugin>
 74                     <artifactId>maven-clean-plugin</artifactId>
 75                     <version>3.0.0</version>
 76                 </plugin>
 77                 <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
 78                 <plugin>
 79                     <artifactId>maven-resources-plugin</artifactId>
 80                     <version>3.0.2</version>
 81                 </plugin>
 82                 <plugin>
 83                     <artifactId>maven-compiler-plugin</artifactId>
 84                     <version>3.7.0</version>
 85                 </plugin>
 86                 <plugin>
 87                     <artifactId>maven-surefire-plugin</artifactId>
 88                     <version>2.20.1</version>
 89                 </plugin>
 90                 <plugin>
 91                     <artifactId>maven-jar-plugin</artifactId>
 92                     <version>3.0.2</version>
 93                 </plugin>
 94                 <plugin>
 95                     <artifactId>maven-install-plugin</artifactId>
 96                     <version>2.5.2</version>
 97                 </plugin>
 98                 <plugin>
 99                     <artifactId>maven-deploy-plugin</artifactId>
100                     <version>2.8.2</version>
101                 </plugin>
102             </plugins>
103         </pluginManagement>
104     </build>
105 </project>

 

 

二、建立系统管理模块

 前几步方法同上 ,

点击后IDEA会生成archetype,但是速度非常慢,如下图所示

解决方法如下:

打开setting,在VM Options内输入 -DarchetypeCatalog=internal,重启idea即可

新模块完成后,在父模块pom.xm中会自动添加模块引用

 由于系统管理模块依赖公共模块,所以要在本模块上增加对公共模块的引用

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 
 3 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 5     <parent>
 6         <artifactId>xframe</artifactId>
 7         <groupId>xie.frame</groupId>
 8         <version>1.0-SNAPSHOT</version>
 9     </parent>
10     <modelVersion>4.0.0</modelVersion>
11 
12     <artifactId>xframe-system</artifactId>
13 
14     <name>xframe-system</name>
15     <packaging>jar</packaging>
16     <properties>
17         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18         <maven.compiler.source>1.8</maven.compiler.source>
19         <maven.compiler.target>1.8</maven.compiler.target>
20     </properties>
21 
22     <dependencies>
23         <dependency>
24             <groupId>junit</groupId>
25             <artifactId>junit</artifactId>
26         </dependency>
27         <dependency>
28             <groupId>xie.frame</groupId>
29             <artifactId>xframe-common</artifactId>
30             <version>${project.version}</version>
31         </dependency>
32     </dependencies>
33 
34 </project>

然后添加系统管理模块的引用包,添加完毕后如下

posted @ 2018-08-02 17:10  疯狗强尼  阅读(1135)  评论(0编辑  收藏  举报