SpringMVC Web项目升级为Springboot项目(一)
一、项目改为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项目(一)的更多相关文章
- SpringMVC Web项目升级为Springboot项目(二)
一.访问原项目地址,报404错误 由于原项目地址启动路径为http://localhost:8080/xxx Spring boot默认启动路径为http://localhost:8080/ 所以需要 ...
- 在同一个tomcat下部署多个springboot项目时,springboot项目无法正常启动的问题
这个问题是基于,不使用springboot内置的tomcat会产生(即使用自己的tomcat时). 今天在部署springboot项目的时候遇到了一个问题,怎么部署都访问不了,在网上查了很多原因,什么 ...
- maven项目改造成springboot项目
springboot项目其实归根到底就是一个maven项目,通常我们创建springboot项目,只要使用idea中的spring Initializr就可以创建就可以了. 今天我们来讲下如何改造一个 ...
- idea设置项目【非springboot项目】热部署
1.首先打开Edit Configurations 或者 2.添加的项目一定是war: exploded,而不是war 3.server这边,On 'Update' action选Redeploy,O ...
- springBoot 项目war包部署及改为war包后资源路径错误问题
参考资料: https://blog.csdn.net/rico_zhou/article/details/83415114 https://blog.csdn.net/pz641/article/d ...
- 从零开始的SpringBoot项目 ( 五 ) 整合 Swagger 实现在线API文档的功能
综合概述 spring-boot作为当前最为流行的Java web开发脚手架,越来越多的开发者选择用其来构建企业级的RESTFul API接口.这些接口不但会服务于传统的web端(b/s),也会服务于 ...
- 从零开始的SpringBoot项目 ( 四 ) 整合mybatis
一.创建一个SpringBoot项目 从零开始的SpringBoot项目 ( 二 ) 使用IDEA创建一个SpringBoot项目 二.引入相关依赖 <!--mysql数据库驱动--> & ...
- 超简单的 Docker部署 SpringBoot项目 步骤
很久之前就用过,一直没有好好写篇博客,今天就总结一下 创建一个 SpringBoot项目 创建一个SpringBoot项目并打成jar包,结构如图 编写 Dockerfile文件 FROM java: ...
- 使用 IDEA 创建 SpringBoot 项目(详细介绍)+ 源码案例实现
使用 IDEA 创建 SpringBoot 项目 一.SpringBoot 案例实现源码 二.SpringBoot 相关配置 1. 快速创建 SpringBoot 项目 1.1 新建项目 1.2 填写 ...
随机推荐
- ffmpeg学习目录收集
ffmpeg工具参数中文详细解释 雷霄骅 - [总结]FFMPEG视音频编解码零基础学习方法
- Windows Internals 笔记——进程
1.一般将进程定义成一个正在运行的程序的一个实例,由以下两部分构成: 一个内核对象,操作系统用它来管理进程,内核对象也是系统保存进程统计信息的地方. 一个地址空间,其中包含所有可执行文件或DLL模块的 ...
- CAS tomcat6搭建
#genkey:在tomcat根目录下keytool -genkey -alias tomcat_cas -keyalg RSA -storepass changeit -keystore serve ...
- session简介与生命周期
session简介 在计算机专业术语中,Session是指一个终端用户与交互系统进行通信的时间间隔,通常指从注册进入系统到注销退出系统之间所经过的时间以及如果需要的话,可能还有一定的操作空间. 具体到 ...
- python设计模式---结构型之门面模式
门面,系统,客户端~ from django.test import TestCase class Hotelier: def __init__(self): print('Arranging the ...
- 参数ref与out
通常我们向方法中传递的是值,方法获得的是这些值的一个拷贝,然后使用这些拷贝,当方法运行完毕后,这些拷贝将被丢弃,而原来的值不会受到影响. 这种情况是通常的,当然还有另外一种情况,我们向方法传递参数的形 ...
- Redis哈希表总结
本文及后续文章,Redis版本均是v3.2.8 在文章<Redis 数据结构之dict><Redis 数据结构之dict(2)>中,从代码层面做了简单理解.总感觉思路的不够条理 ...
- python基础篇_005_迭代器和生成器
Python迭代器和生成器 1.迭代器 迭代:可以将某个数据集内的数据“一个挨着一个的取出来” for i in range(1, 10, 2): # in 后面的对象必须是一个可迭代的 print( ...
- 业务线--node中间层做一个透传的项目
1,node中间层总结 1,ejs引入vue的js,路由层(直接透传,自定义行的),比较浅层的一层 中间件的引入 ? ) { // 与rd约定,接口成功返回code===0,其余为失败 console ...
- 关于Function Language(函数式语言是什么?包含哪些语言?为什么函数式语言流行?)
1.What? Function Language是一种非冯诺依曼式的程序设计语言.函数式语言的主要成分是原始函数.定义函数和函数型. 这种语言具有较强的组织数据结构的能力,可以把某一数据结构(如数组 ...