jar文件包括Java普通类、资源文件和普通文件,在maven中即是打包src/main/java和src/main/resources资源文件夹下的所有文件。在打包的时候会自动生成MATA-INF文件夹,用于存储maven的pom信息和MANIFEST.MF文件。
war文件包含全部的web应用程序,即所有的java类,配置信息和jsp、js等静态资源。但是需要注意war引用war的时候会将应用war的资源全部拷贝到当前war的相同文件下,重名的文件会被替换
.
GroupID是项目组织唯一的标识符,实际对应Java的包的结构
ArtifactID就是项目的唯一的标识符,实际对应项目的名称,就是项目根目录的名称。
一般GroupID就是填com.info.test.这样子。
1、创建project
2、新建Directory
其中,groupon是一个project
Admin,Service,Site分别是Module
4、为每个目录下添加标准工程结构
(以Admin下的Controller为例)
-src
-main
-java
-resources
-test
-java
-resources
5、添加pom.xml文件
对于groupon
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0modelVersion>
<groupId>com.tortuousroadgroupId>
<artifactId>grouponartifactId>
<version>1.0version>
<packaging>pompackaging>
<name>${project.artifactId}name>
<modules>
<module>Adminmodule>
<module>Servicemodule>
<module>Sitemodule>
modules>
<dependencies>
<dependency>
<groupId>org.projectlombokgroupId>
<artifactId>lombokartifactId>
<version>1.16.10version>
dependency>
dependencies>
project>
对Admin
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0modelVersion>
<parent>
<groupId>com.tortuousroadgroupId>
<artifactId>grouponartifactId>
<version>1.0version>
parent>
<groupId>com.tortuousroadgroupId>
<artifactId>groupon-adminartifactId>
<version>1.0version>
<packaging>pompackaging>
<name>${project.artifactId}name>
<modules>
<module>Controllermodule>
<module>Webmodule>
modules>
project>
Service
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0modelVersion>
<parent>
<groupId>com.tortuousroadgroupId>
<artifactId>grouponartifactId>
<version>1.0version>
parent>
<groupId>com.tortuousroadgroupId>
<artifactId>groupon-serviceartifactId>
<version>1.0version>
<packaging>jarpackaging>
<name>${project.artifactId}name>
project>
Site
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0modelVersion>
<groupId>com.tortuousroadgroupId>
<artifactId>grouponartifactId>
<version>1.0version>
<packaging>pompackaging>
<name>${project.artifactId}name>
<modules>
<module>Adminmodule>
<module>Servicemodule>
<module>Sitemodule>
modules>
<dependencies>
<dependency>
<groupId>org.projectlombokgroupId>
<artifactId>lombokartifactId>
<version>1.16.10version>
dependency>
dependencies>
project>
Admin->Controller
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0modelVersion>
<parent>
<groupId>com.tortuousroadgroupId>
<artifactId>groupon-adminartifactId>
<version>1.0version>
parent>
<groupId>com.tortuousroadgroupId>
<artifactId>groupon-admin-controllerartifactId>
<version>1.0version>
<packaging>jarpackaging>
<name>${project.artifactId}name>
project>
Admin->Web
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0modelVersion>
<parent>
<groupId>com.tortuousroadgroupId>
<artifactId>groupon-adminartifactId>
<version>1.0version>
parent>
<groupId>com.tortuousroadgroupId>
<artifactId>groupon-admin-webartifactId>
<version>1.0version>
<packaging>warpackaging>
<name>${project.artifactId}name>
project>
Site->Controller
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0modelVersion>
<parent>
<groupId>com.tortuousroadgroupId>
<artifactId>groupon-siteartifactId>
<version>1.0version>
parent>
<groupId>com.tortuousroadgroupId>
<artifactId>groupon-site-controllerartifactId>
<version>1.0version>
<packaging>jarpackaging>
<name>${project.artifactId}name>
project>
Site->Web
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0modelVersion>
<parent>
<groupId>com.tortuousroadgroupId>
<artifactId>groupon-siteartifactId>
<version>1.0version>
parent>
<groupId>com.tortuousroadgroupId>
<artifactId>groupon-site-webartifactId>
<version>1.0version>
<packaging>warpackaging>
<name>${project.artifactId}name>
project>