Ssm + maven (modular) Framework (eclipse) (I), ssmmaven
Environment: Tomcat 8 + jdk: 1.8 + myeclipse
Reference blog: http://blog.csdn.net/yu870646595/article/details/52150027
1. maven modular construction
Directory framework:
Note: ssm-parent: parent module ssm-module1: child module
Ssm-parent: Aggregates sub-modules, stores jar package dependencies, and shares dependencies between sub-modules;
Pom file Configuration:
<Projectxmlns =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>
<! -- Parent module coordinate gav -->
<GroupId> gxrong. study. ssm </groupId>
<ArtifactId> ssm-parent </artifactId>
<Version> 0.0.1-SNAPSHOT </version>
<! -- Packaging method -->
<Packaging> pom </packaging>
<Name> ssm-parent </name>
<Url> http://maven.apache.org </url>
<! -- Attribute labels can be customized. Here, we mainly manage the version of each dependency. -->
<Properties>
<Project. build. sourceEncoding> UTF-8 </project. build. sourceEncoding>
<! -- Framework dependency versions -->
<Spring. version> 4.2.5.RELEASE </spring. version>
<Mybatis. version> 3.3.1 </mybatis. version>
<Jackson-version> 2.6.4 </jackson-version>
<Commons-io.version> 2.4 </commons-io.version>
<Commons. fileupload. version> 1.3.1 </commons. fileupload. version>
<Slf4j. version> 1.7.7 </slf4j. version>
<Log4j. version> 1.2.17 </log4j. version>
<Junit. version> 4.12 </junit. version>
</Properties>
<! -- Dependencies can be inherited from each sub-module. If some jar sub-modules do not need to be inherited, <dependencies> Add <dependencyManagement> to the outer layer. In this way, sub-modules are not actually added, configure the ga in the pom for the required sub-module. -->
<Dependencies>
<Dependency>
<GroupId> junit </groupId>
<ArtifactId> junit </artifactId>
<Version >$ {junit. version} </version>
<Scope> test </scope>
</Dependency>
<! -- Spring -->
<Dependency>
<GroupId> org. springframework </groupId>
<ArtifactId> spring-core </artifactId>
<Version >$ {spring. version} </version>
<! -- Exclude spring dependency comm-logging and use slf4j as the abstract access layer -->
<Exclusions>
<Exclusion>
<ArtifactId> commons-logging </artifactId>
<GroupId> commons-logging </groupId>
</Exclusion>
</Exclusions>
</Dependency>
<Dependency>
<GroupId> org. springframework </groupId>
<ArtifactId> spring-beans </artifactId>
<Version >$ {spring. version} </version>
</Dependency>
</Dependencies>
Plug-ins
<Build>
<Plugins>
<Plugin>
<GroupId> org. apache. maven. plugins </groupId>
<ArtifactId> maven-compiler-plugin </artifactId>
</Plugin>
<! -- The sub-module name must be the same as the sub-module name. When packaging multiple sub-modules, you can directly perform the configuration on the parent module. -->
<Modules>
<Module> ssm-module1 </module>
</Modules>
</Project>
Sub-Module Directory and POM:
Directory:
Maven standardization structure: src/main/java src/mian/resources src/test/java src/test/resources
File description:
Src/main/java: java code such as dao service controller pojo can be put here. Of course, dao service can create a sub-module separately. This is not a problem of the Project architecture;
Src/mian/resources: Stores project configuration files, such as spring-mybatis log4j;
POM Configuration:
<ArtifactId> ssm-module1 </artifactId>
<Name> ssm-module1 </name>
<Packaging> war </packaging>
<Parent>
<GroupId> gxrong. study. ssm </groupId>
<ArtifactId> ssm-parent </artifactId>
<Version> 0.0.1-SNAPSHOT </version>
</Parent>
Other dependencies are jar dependencies, which mainly indicate parent introduction. The coordinates of the parent module must be placed in the sub-module pom to inherit the dependencies in the parent pom file, the coordinates of the sub-module can be omitted from the groupId version, and the project automatically inherits the configuration of the parent module;
Aggregate inheritance: aggregation is mainly used to facilitate project construction, and inheritance is mainly used to eliminate repeated configurations.
Finally, my blog is a bit messy. For the first time I recorded my own learning in this system, I am sorry.