一、项目改为Springboot项目

1.将pom中所有spring相关依赖删除,添加spring-boot-starter及spring-boot-starter-web(项目中可能有其他spring依赖,单独添加即可)

2.将pom中mybatis相关依赖删除,添加mybatis-spring-boot-starter

3.添加application.properties文件,在其中配置数据库相关配置项

spring.datasource.url=jdbc:mysql://202.16.199.1:3306/Book?useSSL=true&verifyServerCertificate=false&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=123123
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.max-idle=10
spring.datasource.max-wait=10000
spring.datasource.min-idle=5
spring.datasource.initial-size=5

4.添加Application类

package com.gauge.childheart;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; @SpringBootApplication
@RestController
@ComponentScan(basePackages = "com.gauge.childheart.*")
@MapperScan(value = "com.gauge.childheart.mapper")
public class Application extends SpringBootServletInitializer { public static void main(String[] args) {
SpringApplication.run(Application.class, args);
} @RequestMapping("/")
public String hello() {
return "hello";
}
}

5.报错:Consider defining a bean of type xxxxMapper in your configuration

在Application类添加注解@MapperScan(value = "com.xxxx.mapper")

至此,项目可以正常启动

SpringMVC Web项目升级为Springboot项目(一)的更多相关文章

  1. SpringMVC Web项目升级为Springboot项目(二)

    一.访问原项目地址,报404错误 由于原项目地址启动路径为http://localhost:8080/xxx Spring boot默认启动路径为http://localhost:8080/ 所以需要 ...

  2. 在同一个tomcat下部署多个springboot项目时,springboot项目无法正常启动的问题

    这个问题是基于,不使用springboot内置的tomcat会产生(即使用自己的tomcat时). 今天在部署springboot项目的时候遇到了一个问题,怎么部署都访问不了,在网上查了很多原因,什么 ...

  3. maven项目改造成springboot项目

    springboot项目其实归根到底就是一个maven项目,通常我们创建springboot项目,只要使用idea中的spring Initializr就可以创建就可以了. 今天我们来讲下如何改造一个 ...

  4. idea设置项目【非springboot项目】热部署

    1.首先打开Edit Configurations 或者 2.添加的项目一定是war: exploded,而不是war 3.server这边,On 'Update' action选Redeploy,O ...

  5. springBoot 项目war包部署及改为war包后资源路径错误问题

    参考资料: https://blog.csdn.net/rico_zhou/article/details/83415114 https://blog.csdn.net/pz641/article/d ...

  6. 从零开始的SpringBoot项目 ( 五 ) 整合 Swagger 实现在线API文档的功能

    综合概述 spring-boot作为当前最为流行的Java web开发脚手架,越来越多的开发者选择用其来构建企业级的RESTFul API接口.这些接口不但会服务于传统的web端(b/s),也会服务于 ...

  7. 从零开始的SpringBoot项目 ( 四 ) 整合mybatis

    一.创建一个SpringBoot项目 从零开始的SpringBoot项目 ( 二 ) 使用IDEA创建一个SpringBoot项目 二.引入相关依赖 <!--mysql数据库驱动--> & ...

  8. 超简单的 Docker部署 SpringBoot项目 步骤

    很久之前就用过,一直没有好好写篇博客,今天就总结一下 创建一个 SpringBoot项目 创建一个SpringBoot项目并打成jar包,结构如图 编写 Dockerfile文件 FROM java: ...

  9. 使用 IDEA 创建 SpringBoot 项目(详细介绍)+ 源码案例实现

    使用 IDEA 创建 SpringBoot 项目 一.SpringBoot 案例实现源码 二.SpringBoot 相关配置 1. 快速创建 SpringBoot 项目 1.1 新建项目 1.2 填写 ...

随机推荐

  1. php的参数函数与可变参

    在php5.5及更早的版本中,使用func_num_args(), func_get_arg(), func_get_args()函数实现. <?php function myfunc(){ / ...

  2. socket.io中 connect与connection的区别

    参考网址:https://blog.csdn.net/sinat_18474835/article/details/80115961

  3. vue静态文件处理

    前言: vue-cli在创建项目的时候, 会创建两个存放静态文件的目录, 1. src/assets 2. /static 这两个文件夹在项目中的作用和区别是什么, 我们今天就来看一下 静态资源处理: ...

  4. 关于在windows上远行的虚拟机为ubuntu16.04中不能复制和粘贴的问题解决方案

    Linux安装 VMware tools 工具解决复制和粘贴的方法 VMware虚拟机中如何安装VMWare-Tools详解好处:可以支持图形界面,可以支持共享文件功能等 1 工具/原料 1)安装过虚 ...

  5. [原创]Zynq AXI-CDMA测试结果

    经过研究与demo,在zynq上使用axi-cmda效率还是很高,测试报告如下所示 对于读取32KB,GP0和HP0的测试结果如下:

  6. js处理有序列表、js处理无序列表

    有序列表.无序列表 显示id为s下所有的li..隐藏同样 $("#s li").show();

  7. 友元(friend)

    1.友元类的关系不能传递和继承 ...待续

  8. sybase central 报 NullPointerException 解决

    准备发布版本,但是要创建数据库的时候遇到了问题,发现之前可以正常打开的sybase Central 现在无法打开了.苦恼一段时间后找到如下解决方法. 报错如下: 解决如下: 正常打开:

  9. pymongo使用手册

    MongoDB是由C++语言编写的非关系型数据库,是一个基于分布式文件存储的开源数据库系统,其内容存储形式类似JSON对象,它的字段值可以包含其他文档.数组及文档数组,非常灵活.在这一节中,我们就来看 ...

  10. markdown改变字体颜色和大小

    markdown中改变字体颜色与大小方法同html 先看例子 <font face="黑体">我是黑体字</font> 我是黑体字 <font fac ...