zoukankan      html  css  js  c++  java
  • SpringMVC+Spring+mybatis 项目实践

    创建Maven项目

     项目创建完成后导入相关文件

     配置相关依赖

    <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.3.1.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.example</groupId>
        <artifactId>Demo</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>Demo</name>
        <description>Demo project for Spring Boot</description>
    
        <properties>
            <java.version>1.8</java.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.mybatis.spring.boot</groupId>
                <artifactId>mybatis-spring-boot-starter</artifactId>
                <version>2.1.3</version>
            </dependency>
    
            <dependency>
                <groupId>tk.mybatis</groupId>
                <artifactId>mapper-spring-boot-starter</artifactId>
                <version>2.1.4</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
                <scope>runtime</scope>
                <optional>true</optional>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <optional>true</optional>
            </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>
    
            <dependency>
                <groupId>com.microsoft.sqlserver</groupId>
                <artifactId>mssql-jdbc</artifactId>
                <scope>runtime</scope>
            </dependency>
    
            <!-- 使用 jsp 必要依赖 -->
            <dependency>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-jasper</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-thymeleaf</artifactId>
                <version>2.3.1.RELEASE</version>
            </dependency>
    
        </dependencies>
        <pluginRepositories>
            <pluginRepository>
                <id>alimaven spring plugin</id>
                <name>alimaven spring plugin</name>
                <url>https://maven.aliyun.com/repository/spring-plugin</url>
            </pluginRepository>
        </pluginRepositories>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>2.3.1.RELEASE</version>
                </plugin>
            </plugins>
        </build>

    配置数据库

    配置显示页面

     

     添加一个mybatis的mapper库

     修改servlet代码

     运行:

     

    效果和MVC2项目相同

     

     

     

     码云地址:https://gitee.com/xmr123/JAVAEE/tree/feature-SSM

  • 相关阅读:
    esper(4-5)- Context 条件
    esper(4-4)-OverLapping Context
    esper(4-3)-Non-Overlapping Context
    esper(4-2)-Category Context
    esper(4-1)-简单context
    esper(3)-窗口&聚合分组
    esper(2)-事件类型
    java常用代码
    idea(3)-jetty配置
    BP(反向传播)算法原理及推导
  • 原文地址:https://www.cnblogs.com/543123abcxmr/p/13196623.html
Copyright © 2011-2022 走看看