ssm框架整合,pom.xml依赖分析

声明,使用spring5.0.7.RELEASE /mybatis3.4.6/mysql8/JDK8进行整合;

采用父工程子模块方式
整合分2大部分:
spring和springmvc、spring和mybatis整合

spring和springmvc、

1、分别搭建spring以及springmvc,spring和springmvc是无缝结合的,这也是spring火热的重要原因之一;
2、下面分析下spring整合springmvc都需要哪些依赖,这里简写只写artifactId
①spring整合junit 、打印日志
junit/spring-test/slf4j-log4j12
②spring中xml和注解配合使用
spring-context
③spring 核心ioC和AOP,使用到事务就要用到jdbcTemplate以及事务相关的依赖
spring-jdbc/druid/spring-aspects/spring-tx
要连接数据库吧
mysql-connector-java
springmvc需要哪些依赖呢?web项目、、jsp、jstl、servlet处理json的jackson等
spring-webmvc、spring-web/servlet-api/jsp-api、jstl、jackson-databind

spring和mybatis整合、

mybatis作为持久层框架、处理dao层,除了引入mybatis相关的依赖,整合需要引入mybatis-spring相结合的依赖;
1、spring整合mybatis
mybatis、mybatis-spring/连接数据库、DataSource、log4j都已存在、/
Jackson-databind 、jsp、servlet等均已存在

其他配置:

tomcat7 插件
mapper.xml若放在mapper目录下,不放在resources目录下,maven工程加在不到的;
需配置指定加载xml的配置在pom文件中;



<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">
    <parent>
        <artifactId>baidu-parentartifactId>
        <groupId>com.baidu.parentgroupId>
        <version>0.0.1-SNAPSHOTversion>
    parent>
    <modelVersion>4.0.0modelVersion>

    <groupId>com.baidugroupId>
    <artifactId>ssmartifactId>
    <version>0.0.1-SNAPSHOTversion>
    <packaging>warpackaging>

    <name>ssm Maven Webappname>
    
    <url>http://www.example.comurl>

    <properties>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <maven.compiler.source>1.7maven.compiler.source>
        <maven.compiler.target>1.7maven.compiler.target>
    properties>
    
    <dependencies>
        
        <dependency>
            <groupId>junitgroupId>
            <artifactId>junitartifactId>
        dependency>
        <dependency>
            <groupId>org.slf4jgroupId>
            <artifactId>slf4j-log4j12artifactId>
        dependency>
        
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-contextartifactId>
        dependency>
        
        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-jdbcartifactId>
        dependency>
        <dependency>
            <groupId>com.alibabagroupId>
            <artifactId>druidartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-testartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-aspectsartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-txartifactId>
            <version>5.0.7.RELEASEversion>
        dependency>

        
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-webartifactId>
            <version>5.0.7.RELEASEversion>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-webmvcartifactId>
        dependency>
        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>servlet-apiartifactId>
        dependency>
        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>jsp-apiartifactId>
        dependency>
        <dependency>
            <groupId>jstlgroupId>
            <artifactId>jstlartifactId>
        dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.coregroupId>
            <artifactId>jackson-databindartifactId>
        dependency>

        
        
        <dependency>
            <groupId>org.mybatisgroupId>
            <artifactId>mybatisartifactId>
        dependency>
        <dependency>
            <groupId>org.mybatisgroupId>
            <artifactId>mybatis-springartifactId>
        dependency>



    dependencies>

    <build>
        <finalName>ssmfinalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-clean-pluginartifactId>
                    <version>3.0.0version>
                plugin>
                
                <plugin>
                    <artifactId>maven-resources-pluginartifactId>
                    <version>3.0.2version>
                plugin>
                <plugin>
                    <artifactId>maven-compiler-pluginartifactId>
                    <version>3.7.0version>
                plugin>
                <plugin>
                    <artifactId>maven-surefire-pluginartifactId>
                    <version>2.20.1version>
                plugin>
                <plugin>
                    <artifactId>maven-war-pluginartifactId>
                    <version>3.2.0version>
                plugin>
                <plugin>
                    <artifactId>maven-install-pluginartifactId>
                    <version>2.5.2version>
                plugin>
                <plugin>
                    <artifactId>maven-deploy-pluginartifactId>
                    <version>2.8.2version>
                plugin>
                
                <plugin>
                    <groupId>org.apache.tomcat.mavengroupId>
                    <artifactId>tomcat7-maven-pluginartifactId>
                    <configuration>
                        <port>8080port>
                        <path>/path>
                        <uriEncoding>utf-8uriEncoding>
                    configuration>
                plugin>
            plugins>
        pluginManagement>

        <resources>
            <resource>
                <directory>src/main/javadirectory>
                <includes>
                    <include>**/*.xmlinclude>
                includes>
                <filtering>truefiltering>
            resource>
            <resource>
                <directory>src/main/resourcesdirectory>
                <includes>
                    <include>**/*.xmlinclude>
                    <include>**/*.propertiesinclude>
                includes>
            resource>
        resources>

    build>
project>

你可能感兴趣的:(Spring框架)