java:maven(maven-ssm(聚合,分包开发))
Posted 咫尺天涯是路人丶
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java:maven(maven-ssm(聚合,分包开发))相关的知识,希望对你有一定的参考价值。
1.maven-ssm:
maven-ssm_diy:
pom.xml:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="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> <groupId>cn.zzsxt</groupId> <artifactId>maven-ssm_diy</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <!-- tomcat7插件 --> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <port>8080</port> <path>/crud</path> </configuration> </plugin> </plugins> </build> <!-- 聚合子模块,添加子模块时自动添加 --> <modules> <module>maven-ssm-dao</module> <module>maven-ssm-service</module> <module>maven-ssm-web</module> </modules> <properties> <!-- 版本声明 --> <spring.version>4.3.9.RELEASE</spring.version> <aspectj.version>1.8.9</aspectj.version> <mybatis.version>3.4.1</mybatis.version> <mybatis-spring.version>1.3.0</mybatis-spring.version> <c3p0.version>0.9.5.2</c3p0.version> <mysql.version>5.1.38</mysql.version> <log4j.version>1.2.17</log4j.version> <slf4j.version>1.7.25</slf4j.version> <slf4j-log4j12.version>1.7.21</slf4j-log4j12.version> <javaee-version>7.0</javaee-version> <servlet-version>3.1.0</servlet-version> <jsp-version>2.2</jsp-version> <jstl-version>1.2</jstl-version> </properties> <dependencyManagement> <dependencies> <!-- javaee7 --> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>${javaee-version}</version> <scope>provided</scope> </dependency> <!-- servlet api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>${servlet-version}</version> <scope>provided</scope> </dependency> <!-- jsp api --> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>${jsp-version}</version> <scope>provided</scope> </dependency> <!-- jstl --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>${jstl-version}</version> </dependency> </dependencies> </dependencyManagement> <!-- jar文件依赖 --> <!-- spring --> <dependencies> <!-- spring-context依赖spring-core,spring-beans,spring-aop,commons-logging,spring-expression,spring-context --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <!-- spring-test --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> <scope>test</scope> </dependency> <!-- spring-webmvc依赖spring-web --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <!-- spring-jdbc,spring-tx --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <!-- spring-context-support --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <!-- spring-orm,spring-core,spring-beans,common-logging,spring-jdbc,spring-tx --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring.version}</version> </dependency> <!-- spring-aspects,aspectjweaver --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>${aspectj.version}</version> </dependency> <!-- mybatis --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <!-- mybatis-spring --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>${mybatis-spring.version}</version> </dependency> <!-- c3p0 --> <dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>${c3p0.version}</version> </dependency> <!-- mysql --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency> <!-- log4j --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <!-- slf4j --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j-log4j12.version}</version> <scope>test</scope> </dependency> <!-- junit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies> </project>
maven-ssm-dao:
pom.xml:
<project xmlns="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> <groupId>cn.zzsxt</groupId> <artifactId>maven-ssm_diy</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>maven-ssm-dao</artifactId> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project>
applicationContext-dao.xml:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- 扫描注解包 --> <context:component-scan base-package="cn.zzsxt.ssm"></context:component-scan> <!-- 数据源 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="com.mysql.jdbc.Driver"></property> <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/test"></property> <property name="user" value="root"></property> <property name="password" value="root"></property> </bean> <!-- 配置SqlSessionFactory,并注入数据源 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <!-- 加载cn/zzsxt/ssm/mapper/所有以 Mapper.xml结尾的映射文件 --> <property name="mapperLocations" value="classpath:cn/zzsxt/ssm/mapper/*Mapper.xml"></property> </bean> <!-- 配置MapperScannerConfigurer,用于扫描指定包下的Mapper接口,生成代理对象的id为Mapper接口名第一个字母小写 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactory" ref="sqlSessionFactory"></property> <property name="basePackage" value="cn.zzsxt.ssm.mapper"></property> </bean> </beans>
log4j.properties:
log4j.rootLogger=DEBUG, Console
log4j.appender.Console=org.apache.log4j以上是关于java:maven(maven-ssm(聚合,分包开发))的主要内容,如果未能解决你的问题,请参考以下文章
02-Maven高级-分模块开发依赖传递聚合继承(SpringBoot的部分底层原理)多模块开发(环境切换)Nexus私服搭建与使用