9. SpringMVC整合

数据库初始化

DROP TABLE IF EXISTS `book`;
CREATE TABLE `book` (
  `Id` int(11) NOT NULL,
  `Name` varchar(200) NOT NULL,
  `Count` int(11) DEFAULT NULL,
  `Memo` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO book (Id, Name, Count, Memo)
VALUES (1, 'Java', 1, '从入门到放弃'),
(2, 'MySql', 10, '从删库到跑路'),
(3, 'Linux', 1, '从入门到上路')

代码结构搭建

  1. 创建新的Maven项目!
  2. 导入依赖


    
    
        junit
        junit
        4.12
        test
    
    
    
        mysql
        mysql-connector-java
        8.0.25
    
    
    
        com.mchange
        c3p0
        0.9.5.5
    
    
    
        javax.servlet
        servlet-api
        2.5
    
    
        javax.servlet.jsp
        jsp-api
        2.2
    
    
        javax.servlet
        jstl
        1.2
    
    
    
        org.mybatis
        mybatis
        3.5.2
    
    
        org.mybatis
        mybatis-spring
        2.0.2
    
    
    
        org.springframework
        spring-webmvc
        5.3.14
    
    
        org.springframework
        spring-jdbc
        5.1.9.RELEASE
    
    
    
        org.projectlombok
        lombok
        1.16.10
    

  1. 静态资源到处问题
    
        
            
                src/main/java
                
                    **/*.properties
                    **/*.xml
                
                false
            
            
                src/main/resources
                
                    **/*.properties
                    **/*.xml
                
                false
            
        
    

你可能感兴趣的:(9. SpringMVC整合)