ssm整合IDEA版本

ssm整合方式一

创建项目

首先使用IDEA创建一个基于maven的web项目

ssm整合IDEA版本_第1张图片

ssm整合IDEA版本_第2张图片

Next然后finish即可,创建完成然后再main下创建两文件java和resources,选中java右键选择Make Directory as->Sources Root;java文件夹的颜色会发生变化。同样选中resources文件夹Make Directory as->Resources Root

ssm整合IDEA版本_第3张图片

创建基本包结构,完整的项目目录如下

ssm整合IDEA版本_第4张图片

所有依赖的包



    4.3.10.RELEASE

    4.2.3.RELEASE

    1.2

    2.5







    

    

        org.springframework

        spring-core

        ${spring.version}

    

    

        org.springframework

        spring-web

        ${spring.version}

    

    

        org.springframework

        spring-webmvc

        ${spring.version}

    

    

    

        org.springframework

        spring-jdbc

        ${spring.version}

    

        

    

        jstl

        jstl

        ${jstl.version}

    

    

        javax.servlet

        servlet-api

        ${servlet.version}

        provided

    

    

    

        com.fasterxml.jackson.core

        jackson-databind

        2.9.5

    

    

    

        org.mybatis

        mybatis

        3.4.4

    

    

    

        org.mybatis

        mybatis-spring

        1.3.0

    

    

    

        com.alibaba

        druid

        1.1.7

    

    

    

        mysql

        mysql-connector-java

        5.1.41

    







    SpringSecurity4Demo

    

        

            src/main/java

            

                **/*.xml

            

            true

        

        

            src/main/resources

            

                **/*.xml

                **/*.properties

            

        

    

 

web.xml

xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
        
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        
version="2.5">
    

 

 
org.springframework.web.context.ContextLoaderListener
 
 
   
contextConfigLocation
   
     
classpath:applicationContent.xml

   
 
 

 

   
DispatcherServlet
   
org.springframework.web.servlet.DispatcherServlet
   
     
contextConfigLocation
     
classpath:Springmvc.xml
   
   

   
1
 
 
   
DispatcherServlet
   
/
 

 

jdbc.properties

jdbc.driver=com.mysql.jdbc.Driver

jdbc.url=jdbc:mysql://localhost:3306/sss?characterEncoding=utf-8

jdbc.username=root

jdbc.password=root

 

applicationContent.xml

xml version="1.0" encoding="UTF-8"?>

xmlns="http://www.springframework.org/schema/beans"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xmlns:content="http://www.springframework.org/schema/context" xmlns:tx="http://www.alibaba.com/schema/stat"

       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.alibaba.com/schema/stat http://www.alibaba.com/schema/stat.xsd">

    

    <content:property-placeholder location="classpath:jdbc.properties"/>

    

    id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">

        name="driverClassName" value="${jdbc.driver}"/>

        name="password" value="${jdbc.password}"/>

        name="username" value="${jdbc.username}"/>

        name="url" value="${jdbc.url}"/>

        name="maxActive" value="10"/>

        name="maxWait" value="3000"/>

    

    

    id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

        name="dataSource" ref="dataSource"/>

        

        name="typeAliasesPackage" value="com.javayihao.top.sss.domain"/>

    

    

    class="org.mybatis.spring.mapper.MapperScannerConfigurer">

        name="basePackage" value="com.javayihao.top.sss.mapper"/>

    

    

    id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

        name="dataSource" ref="dataSource"/>

    

    <tx:annotation-driven/> 

    

    <content:component-scan base-package="com.javayihao.top.sss.service"/>

 

Springmvc.xml

xml version="1.0" encoding="UTF-8"?>

xmlns="http://www.springframework.org/schema/beans"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xmlns:context="http://www.springframework.org/schema/context"

       xmlns:mvc="http://www.springframework.org/schema/mvc"

       xsi:schemaLocation="

  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd

  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd

  http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">



    <context:component-scan base-package="com.javayihao.top.sss.controller"/>

    

    <mvc:annotation-driven>mvc:annotation-driven>

    

    class="org.springframework.web.servlet.view.InternalResourceViewResolver">

        

        name="prefix" value="/WEB-INF/"/>

        

        name="suffix" value=".jsp"/>

    

至此完成,ssm整合已经完成,对于ssm相关的实战项目,可以关注微信公众号 java一号  获取相关实战ssm项目

你可能感兴趣的:(java日常)