• ssm的Demo


    学习了SSM 后将其整合成一个小Demo

    1 结构图

    在这里插入图片描述

    2 config层

    2.1 JdbcConfig (jdbc配置)

    
    public class JdbcConfig {
    
        @Value("${jdbc.driver}")
        private String driver ;
        @Value("${jdbc.url}")
        private String url;
        @Value("${jdbc.username}")
        private String username;
        @Value("${jdbc.password}")
        private String password;
    
        /**
         * 创建 dataSource 的bean
         * @return DataSource
         */
        @Bean
        public DataSource dataSource(){
            DruidDataSource dataSource =new DruidDataSource();
            dataSource.setDriverClassName(driver);
            dataSource.setUrl(url);
            dataSource.setUsername(username);
            dataSource.setPassword(password);
    
            return dataSource;
        }
    
        /**
         *  用于事务控制的bean
         * @param dataSource 参数类型:DataSource 数据库信息
         * @return 事务
         */
        @Bean
        public PlatformTransactionManager transactionManager(DataSource dataSource){
            DataSourceTransactionManager ds =new DataSourceTransactionManager();
            ds.setDataSource(dataSource);
            return ds;
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39

    2.2 MyBatisConfig (MyBatis配置)

    public class MyBatisConfig {
    
        /**
         * sql的会话工程 用于初始化Mybatis
         * @param dataSource
         * @return
         */
        @Bean
        public SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource){
            SqlSessionFactoryBean factoryBean =new SqlSessionFactoryBean();
            factoryBean.setDataSource(dataSource);
            /*
                配置 搜索指定包别名
                不用com.itheima.domain.Book 可以直接Book
             */
            factoryBean.setTypeAliasesPackage("com.itheima.domain");
            return factoryBean;
    
        }
    
        /**
         * 生成Mapper接口的代理
         * @return 返回类型:MapperScannerConfigurer
         */
        @Bean
        public MapperScannerConfigurer mapperScannerConfigurer(){
            MapperScannerConfigurer msc =new MapperScannerConfigurer();
            //配置dao接口的映射mapper
            msc.setBasePackage("com.itheima.dao");
            return msc;
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32

    2.3 ServiceConfig (Service 配置)

    public class ServiceConfig extends AbstractAnnotationConfigDispatcherServletInitializer {
        /**
         * 指定根配置类
         * 将有@Component注解或者@Component注解的配置类提供给根应用上下文
         * RootConfig配置类加载的是驱动应用后端的中间层和数据层组件,是父上下文。
         * @return
         */
        @Override
        protected Class<?>[] getRootConfigClasses() {
            return new Class[]{SpringConfig.class};
        }
    
        /**
         * 指定配置类
         * 将有@Component注解或者@Component注解的配置类提供给根应用上下文
         * WebConfig配置类中主要是内容是启用组件扫描,配置视图解析器,配置静态资源的处理。
         * @return
         */
        @Override
        protected Class<?>[] getServletConfigClasses() {
            return new Class[]{SpringMvcConfig.class};
        }
    
        /**
         * 判断拦截
         * "/" 拦截所有
         * @return
         */
        @Override
        protected String[] getServletMappings() {
            return new String[]{"/"};
        }
    
        /**
         *    乱码处理
         */
    
        @Override
        protected Filter[] getServletFilters() {
            CharacterEncodingFilter filter = new CharacterEncodingFilter();
            filter.setEncoding("UTF-8");
            return new Filter[]{filter};
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44

    2.4 SpringConfig (Spring 配置)

    @Configuration //配置spring容器(应用上下文)
    @ComponentScan("com.itheima.service") //扫描com.itheima.service的bean
    @PropertySource("classpath:jdbc.properties") //读取配置文件
    @Import({JdbcConfig.class, MyBatisConfig.class}) //Import通过快速导入的方式实现把实例加入spring的IOC容器中
    @EnableTransactionManagement
    /**
     *Spring配置
     */
    public class SpringConfig {
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    2.5 SpringMvcConfig (SpringMvc 配置)

    @Configuration //配置springMvc容器(应用上下文)
    @ComponentScan({"com.itheima.controller","com.itheima.config"}) //扫描com.itheima.controller与com.itheima.config的bean
    @EnableWebMvc //向容器登记一组Spring MVC运行时使用的bean
    public class SpringMvcConfig implements WebMvcConfigurer {
    
        @Autowired
        private ProjectInterceptor projectInterceptor;
        @Autowired
        private ProjectInterceptor2 projectInterceptor2;
    
        @Override
        public void addInterceptors(InterceptorRegistry registry) {
            //配置多拦截器
            registry.addInterceptor(projectInterceptor).addPathPatterns("/books","/books/*");
            registry.addInterceptor(projectInterceptor2).addPathPatterns("/books","/books/*");
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    2.6 SpringMvcSupport (SpringMvc拦截器)

    /**
     *  配置SpringMvc拦截器
     */
    @Configuration
    public class SpringMvcSupport extends WebMvcConfigurationSupport {
    
        @Autowired
        private ProjectInterceptor projectInterceptor;
        /**
         * 配置一个拦截器
         * 如果访问路径是addResourceHandler中的filepath 这个路径
         * 那么就 映射到访问本地的addResourceLocations 的参数的这个路径上
         * 用于别人访问服务器的本地文件
         * @param registry
         */
        @Override
        protected void addResourceHandlers(ResourceHandlerRegistry registry) {
            //匹配到resourceHandler,将URL映射至location,也就是本地文件夹
            registry.addResourceHandler("/pages/**").addResourceLocations("/pages/");
            registry.addResourceHandler("/css/**").addResourceLocations("/css/");
            registry.addResourceHandler("/js/**").addResourceLocations("/js/");
            registry.addResourceHandler("/plugins/**").addResourceLocations("/plugins/");
    
        }
    
        /**
         * 配置加载拦截器
         * @param registry
         */
        @Override
        protected void addInterceptors(InterceptorRegistry registry) {
            //配置拦截器
            registry.addInterceptor(projectInterceptor).addPathPatterns("/books","/books/*");
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36

    2 Controller (控制器)

    2.1 interceptor (拦截器)

    2.11 ProjectInterceptor 拦截器一
    @Component
    //定义拦截器类,实现HandlerInterceptor接口
    //注意当前类必须受Spring容器控制
    public class ProjectInterceptor implements HandlerInterceptor {
        @Override
        //原始方法调用前执行的内容
        //返回值类型可以拦截控制的执行,true放行,false终止
        public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
            String contentType = request.getHeader("Content-Type");
            HandlerMethod hm = (HandlerMethod)handler;
            System.out.println("preHandle..."+contentType);
            return true;
        }
    
        @Override
        //原始方法调用后执行的内容
        public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
            System.out.println("postHandle...");
        }
    
        @Override
        //原始方法调用完成后执行的内容
        public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
            System.out.println("afterCompletion...");
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    2.11 ProjectInterceptor2 拦截器2
    /**
     * 配置拦截器2
     */
    @Component
    public class ProjectInterceptor2 implements HandlerInterceptor {
        @Override
        public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    //        String contentType = request.getHeader("Content-Type");
    //        HandlerMethod hm = (HandlerMethod)handler;
            System.out.println("preHandle...222");
            return true;
        }
    
        @Override
        public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
            System.out.println("postHandle...222");
        }
    
        @Override
        public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
            System.out.println("afterCompletion...222");
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    2.2 BookController Book控制器

    
    @RestController //Rest风格的控制器
    @RequestMapping("books") //定控制器可以处理哪些URL请求
    public class BookController {
        @Autowired
        private BookService bookService;
    
        @PostMapping
        public Result save(@RequestBody Book book) {
    
            boolean save = bookService.save(book);
    
            Result result = new Result(save ? Code.Save_ok : Code.Save_ERR, save);
    
            return result;
    
        }
    
        @PutMapping
        public Result update(@RequestBody Book book) {
            boolean update = bookService.update(book);
            Result result = new Result(update ? Code.Update_ok : Code.Update_ERR, update);
            return result;
        }
    
        @DeleteMapping("/{id}")
        public Result delete(@PathVariable Integer id) {
            boolean delete = bookService.delete(id);
            Result result = new Result(delete ? Code.DELETE_ok : Code.DELETE_ERR, delete);
            return result;
        }
    
        @GetMapping("/{id}")
        public Result getById(@PathVariable Integer id) {
            Book byId = bookService.getById(id);
    
            Integer code = byId != null ? Code.GET_ok : Code.GET_ERR;
            String msg =byId != null ? "":"数据查询失败,请重试";
            Result result = new Result(code,byId,msg);
            return result;
        }
    
        @GetMapping
        public Result getAll() {
            List<Book> all = bookService.getAll();
    
            Integer code = all != null ? Code.GET_ok : Code.GET_ERR;
            String msg =all != null ? "":"数据查询失败,请重试";
            Result result = new Result(code,all,msg);
    
            return result;
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54

    2.3 Code (自定义异常编码)

    /*
    * 自定义异常编码
    */
    public class Code {
        //增删改查成功
        public static final Integer Save_ok =20011;
        public static final Integer DELETE_ok =20021;
        public static final Integer Update_ok =20031;
        public static final Integer GET_ok =20041;
    
        //增删改查失败
        public static final Integer Save_ERR =20010;
        public static final Integer DELETE_ERR =20020;
        public static final Integer Update_ERR =20030;
        public static final Integer GET_ERR =20040;
    
        /**
         * 系统错误
         */
        public static final Integer SYSTEM_ERR =50001;
    
        /**
         * 系统时间错误
         */
        public static final Integer System_TIMEOUT_ERR =50002;
    
        /**
         * 业务错误
         */
        public static final Integer BUSINESS_ERR =6002;
    
    
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34

    2.4 ProjectExceptionAdvice (异常处理器)

    /**
     * 用于标识当前类为REST风格对应的异常处理器
     */
    @RestControllerAdvice //@RestControllerAdvice主要用精简客户端返回异常,它可以捕获各种异常
    public class ProjectExceptionAdvice {
    
        /*
        @ExceptionHandler注解我们一般是用来自定义异常的。
        可以认为它是一个异常拦截器(处理器)。
        */
    
    
        //当拦截到系统异常后
        @ExceptionHandler(SystemException.class)
        public Result doSystemException(SystemException ex){
            //记录日志
            //发送信息给运维
            //发送邮件给开发人员
            return new Result(ex.getCode(), null,ex.getMessage());
    
        }
    
        //当拦截到业务异常后
        @ExceptionHandler(BusinessException.class)
        public Result doSystemException(BusinessException ex){
    
            return new Result(ex.getCode(), null,ex.getMessage());
    
        }
        /**
         *   统一处理所有的Exception异常
         */
        @ExceptionHandler(Exception.class)
        public Result doException(Exception ex){
            System.out.println("抓住异常"+ex.getLocalizedMessage());
    
            return new Result(666, null,"出现异常了");
    
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41

    2.5 Result (返回结果)

    //返回结果
    public class Result {
        //数据源
        public Object data;
        //状态码
        public Integer code;
        //信息
        public String msg;
    
        public Result() {
        }
    
        public Result(Integer code, Object data) {
            this.data = data;
            this.code = code;
        }
    
        public Result(Integer code, Object data, String msg) {
            this.data = data;
            this.code = code;
            this.msg = msg;
        }
    
        public Object getData() {
            return data;
        }
    
        public void setData(Object data) {
            this.data = data;
        }
    
        public Integer getCode() {
            return code;
        }
    
        public void setCode(Integer code) {
            this.code = code;
        }
    
        public String getMsg() {
            return msg;
        }
    
        public void setMsg(String msg) {
            this.msg = msg;
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48

    3 dao (数据访问接口)

    3.1 BookDao (对Book表进行操作的接口)

    
    public interface BookDao {
    
        @Insert("insert into tbl_book (type,name,description) values(#{type},#{name},#{description})")
        public int save(Book book);
    
        @Update("update tbl_book set type = #{type}, name = #{name}, description = #{description} where id = #{id}")
        public int update(Book book);
    
        @Delete("delete from tbl_book where id = #{id}")
        public int delete(Integer id);
    
        @Select("select * from tbl_book where id = #{id}")
        public Book getById(Integer id);
    
        @Select("select * from tbl_book")
        public List<Book> getAll();
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    4 domain(实体类)

    • domain
      在domain包下面的实体类其中的属性不仅会包含数据库中的字段,还会包含其他自定义属性

    4.1 Book (Book实体类)

    /**
     * book类
     */
    public class Book {
        private Integer id;
        private String type;
        private String name;
        private String description;
    
        @Override
        public String toString() {
            return "Book{" +
                    "id=" + id +
                    ", type='" + type + '\'' +
                    ", name='" + name + '\'' +
                    ", description='" + description + '\'' +
                    '}';
        }
    
        public Integer getId() {
            return id;
        }
    
        public void setId(Integer id) {
            this.id = id;
        }
    
        public String getType() {
            return type;
        }
    
        public void setType(String type) {
            this.type = type;
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public String getDescription() {
            return description;
        }
    
        public void setDescription(String description) {
            this.description = description;
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52

    5 Exception (异常)

    • 异常(exception)是在运行程序时产生的一种异常情况

    5.1 BusinessException(业务异常类)

    /**
     * 业务异常
     */
    public class BusinessException extends RuntimeException {
    
    
        //异常编号
        private Integer code;
    
        public BusinessException(Integer code, String message) {
            super(message);
            this.code = code;
        }
    
        public BusinessException(Integer code, String message, Throwable cause) {
            super(message, cause);
            this.code = code;
        }
    
        public Integer getCode() {
            return code;
        }
    
        public void setCode(Integer code) {
            this.code = code;
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28

    5.1 SystemException(系统异常类)

    /**
     * 系统异常
     */
    public class SystemException extends RuntimeException {
    
    
        //异常编号
        private Integer code;
    
        public SystemException(Integer code, String message) {
            super(message);
            this.code = code;
        }
    
        public SystemException(Integer code, String message, Throwable cause) {
            super(message, cause);
            this.code = code;
        }
    
        public Integer getCode() {
            return code;
        }
    
        public void setCode(Integer code) {
            this.code = code;
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28

    6 service (服务端)

    • 服务端 对客户提供服务的

    6.1 impl (服务端实现类)

    • 接口
    6.11 BookServiceImpl (book实现类)
    
    @Service
    public class BookServiceImpl implements BookService {
    
        //自动装配
        @Autowired
        private BookDao bookDao;
    
        public boolean save(Book book) {
            return bookDao.save(book) > 0;
        }
    
        public boolean update(Book book) {
            return bookDao.update(book) > 0;
    
        }
    
        public boolean delete(Integer id) {
            return bookDao.delete(id) > 0;
    
        }
    
        public Book getById(Integer id) {
    
            if (id <= 0) {
                throw new BusinessException(Code.BUSINESS_ERR, "请输入正确Id");
            }
    
            try {
                //将可能出现的异常进行包装
                /*  int i = 1 / 0;*/
            } catch (Exception e) {
                throw new BusinessException(Code.SYSTEM_ERR, "服务器超时,请重试");
            }
    
    
            return bookDao.getById(id);
        }
    
        public List<Book> getAll() {
            return bookDao.getAll();
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44

    6.2 BookService (book接口)

    @Transactional //注解形式的事务
    public interface BookService {
        /**
         * 保存
         * @param book
         * @return
         */
        public boolean save(Book book);
    
        /**
         * 修改
         * @param book
         * @return
         */
        public boolean update(Book book);
    
        /**
         * 按id删除
         * @param id
         * @return
         */
        public boolean delete(Integer id);
    
        /**
         * 按id查询
         * @param id
         * @return
         */
        public Book getById(Integer id);
    
        /**
         * 查询全部
         * @return
         */
        public List<Book> getAll();
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37

    7 配置类

    7.1 jdbc.properties (配置文件)

    jdbc.driver=com.mysql.jdbc.Driver
    jdbc.url=jdbc:mysql://81.68.155.110/demo01
    jdbc.username=demo01
    jdbc.password=****
    
    • 1
    • 2
    • 3
    • 4

    pom (项目对象模型)

    <?xml version="1.0" encoding="UTF-8"?>
    
    <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">
      <modelVersion>4.0.0</modelVersion>
    
      <groupId>org.example</groupId>
      <artifactId>SpringMvcTest_01_ssm</artifactId>
      <version>1.0-SNAPSHOT</version>
      <packaging>war</packaging>
    
      <dependencies>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-webmvc</artifactId>
          <version>5.2.10.RELEASE</version>
        </dependency>
    
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-jdbc</artifactId>
          <version>5.2.10.RELEASE</version>
        </dependency>
    
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-test</artifactId>
          <version>5.2.10.RELEASE</version>
        </dependency>
    
        <dependency>
          <groupId>org.mybatis</groupId>
          <artifactId>mybatis</artifactId>
          <version>3.5.6</version>
        </dependency>
    
        <dependency>
          <groupId>org.mybatis</groupId>
          <artifactId>mybatis-spring</artifactId>
          <version>1.3.0</version>
        </dependency>
    
        <dependency>
          <groupId>mysql</groupId>
          <artifactId>mysql-connector-java</artifactId>
          <version>5.1.47</version>
        </dependency>
    
        <dependency>
          <groupId>com.alibaba</groupId>
          <artifactId>druid</artifactId>
          <version>1.1.16</version>
        </dependency>
    
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.12</version>
          <scope>test</scope>
        </dependency>
    
        <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>javax.servlet-api</artifactId>
          <version>3.1.0</version>
          <scope>provided</scope>
        </dependency>
    
        <dependency>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
          <version>2.9.0</version>
        </dependency>
    
      </dependencies>
    
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.1</version>
            <configuration>
              <port>80</port>
              <path>/</path>
            </configuration>
          </plugin>
        </plugins>
      </build>
    
      <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
      </properties>
    
    </project>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
  • 相关阅读:
    LED热仿真笔记
    智慧公厕:科技赋予公共卫生新生命,提升城市管理品质
    Vue(五)——使用脚手架(2)
    Pikachu靶场——URL 重定向
    计算机毕业设计ssm千益校园帮跑腿信息平台5e9ev系统+程序+源码+lw+远程部署
    gRPC之.Net6中的初步使用介绍
    (End)参与工作流研发的这8年
    SElinux avc dennied权限问题解决方法
    青龙脚本分享(不断更新完善)
    STM32通用定时器产生PWM信号
  • 原文地址:https://blog.csdn.net/Rouehang/article/details/127811090