zoukankan      html  css  js  c++  java
  • SpringBoot_04_SpringBoot对ssm的整合

    1.在SpringBoot框架下对ssm进行整合

    2.搭建一个web的SpringBoot框架

     

    2.1添加pom.xml坐标(需要加上SpringBoot对jsp的支持,和对资源文件位置的说明

    <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.1.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <properties>
            <java.version>1.8</java.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <!--mybatis起步依赖-->
            <dependency>
                <groupId>org.mybatis.spring.boot</groupId>
                <artifactId>mybatis-spring-boot-starter</artifactId>
                <version>1.3.2</version>
            </dependency>
    
            <!-- MySQL连接驱动 -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
            </dependency>
    
            <!-- mybatis的启动器 -->
            <dependency>
                <groupId>org.mybatis.spring.boot</groupId>
                <artifactId>mybatis-spring-boot-starter</artifactId>
                <version>1.3.2</version>
            </dependency>
            <!-- 通用mapper的启动器 -->
            <dependency>
                <groupId>tk.mybatis</groupId>
                <artifactId>mapper-spring-boot-starter</artifactId>
                <version>2.0.2</version>
            </dependency>
    
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
            </dependency>
    
            <!--热部署配置-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
            </dependency>
            <!--让springBoot支持jsp-->
            <dependency>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-jasper</artifactId>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
            </dependency>
            <dependency>
                <groupId>javax.servlet.jsp</groupId>
                <artifactId>javax.servlet.jsp-api</artifactId>
                <version>2.3.1</version>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
            </dependency>
    
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.junit.vintage</groupId>
                        <artifactId>junit-vintage-engine</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
          <!--说明资源文件的路径-->
            <resources>
                <resource>
                    <directory>src/main/java</directory>
                    <includes>
                        <include>**/*.xml</include>
                    </includes>
                </resource>
                <resource>
                    <directory>src/main/resources</directory>
                    <includes>
                        <include>**/*.*</include>
                    </includes>
                </resource>
                <resource>
                    <directory>src/main/webapp</directory>
                    <targetPath>META-INF/resources</targetPath>
                    <includes>
                        <include>**/*.*</include>
                    </includes>
                </resource>
            </resources>
        </build>

     

    3.创建webapp文件(注意和java是在同一级目录)

     

     3.1让SpringBoot可以创建.jsp文件

     4.配置mybatis的配置文件和springmvc的视图解析器

    application.properties

    server.port=8080
    #springboot启动动画
    #spring.banner.location=classpath:hdh.txt
    #配置数据库连接
    spring.datasource.url=jdbc:mysql://localhost:3306/ffms
    spring.datasource.username=root
    spring.datasource.password=12345
    # druid连接池
    #初始化连接数
    spring.datasource.druid.initial-size=1
    #最小空闲连接
    spring.datasource.druid.min-idle=1
    #最大活动连接
    spring.datasource.druid.max-active=20
    #获取连接时测试是否可用
    spring.datasource.druid.test-on-borrow=true
    #监控页面启动
    spring.datasource.druid.stat-view-servlet.allow=true
    #spring集成Mybatis环境
    #pojo别名扫描包
    mybatis.type-aliases-package=com.hdh.domain
    #加载Mybatis映射文件
    
    #mybatis.mapper-locations=classpath:mapper/*.xml
    #pagehelper助手
    pagehelper.helperDialect=mysql
    pagehelper.reasonable=true
    pagehelper.supportMethodsArguments=true
    pagehelper.params=count=countSql
    #mvc视图解析器
    #spring.mvc.view.prefix=
    #spring.mvc.view.suffix=
    spring.mvc.view.prefix=/
    spring.mvc.view.suffix=.jsp

     

    配置文件名并不是随意的,配置规则如下:

     

     

     

    测试《完成。。。。。。》

     

    <你是我自罚三杯也不肯开口的秘密>

     

     

     

  • 相关阅读:
    末学者笔记--KVM虚拟化存储管理(3)
    离线安装docker-ce
    OpenStack各组件的常用命令
    docker容器的基本命令
    nfs samba文件共享服务
    kvm虚拟机管理(创建、连接)
    虚拟化kvm的搭建
    python(pymysql操作数据库)
    三大特征 封装 继承 多态
    面向对象
  • 原文地址:https://www.cnblogs.com/asndxj/p/11830458.html
Copyright © 2011-2022 走看看