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 填写 ...
随机推荐
- LINUX常见性能监控工具总结
文章来源 工具功能概览 整理了一个关于监控工具及其功能的表.下面对这些工具单独详细介绍. Linux性能监控工具 top top命令会展示进程的实际活动.默认情况下,它会列出系统上所有cpu密集型任务 ...
- HBuilder只提示html 不提示js
1. 右键行号,点击语法验证器设置 点开Javascript语法验证器 然后修复你js代码中的不规范代码,就会有提示了.
- Ubuntu 18.04LTS 更新镜像配置
清华大学开源镜像站:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/ Ubuntu 的软件源配置文件是 /etc/apt/sources.list.将 ...
- spring boot 2.0 neo4j 使用
参考文档 官方文档 http://spring.io/projects/spring-data-neo4j#learn https://docs.spring.io/spring-data/neo4j ...
- 如何在cocos中为节点添加监听事件
一般在监听键盘事件时,可是采用以下方式来监听键盘事件: 以及记得定义取消监听的函数(这个摧毁函数会自己调用吗?): 同时这里还有一种传统的监听方式: 但是cocos官方的文档建议我们不要使用这种方式, ...
- Redis数据结构之quicklist
本文及后续文章,Redis版本均是v3.2.8 我们在使用Redis对外暴露的list数据结构时,给我们带来极大的便利性.其底层实现所依赖的内部数据结构就是quicklist. 我们先来回忆下list ...
- DDoS攻击与防御(3)
3.攻击应用资源网络应用和服务在处理数据时,通常需要消耗一定的网络连接.计算和存储资源,这些资源是由应用程序向系统进行申请并自行管理和维护的.消耗应用资源的DDoS攻击就是通过向应用提交大量消耗资源的 ...
- Prime Distance POJ - 2689 (数学 素数)
The branch of mathematics called number theory is about properties of numbers. One of the areas that ...
- git 入门教程之分支总览
分支就是一条独立的时间线,既有分支,必有主干,正如一棵树谈到树枝,必有树干一样的道理.我们先前对git 的全部操作默认都是在主干上进行的,这个主干也是一种特殊的分支,名为 master 分支. 无论是 ...
- (三)ajax请求不同源之cors跨域
一.基本原理 CORS是一个W3C标准,全称是"跨域资源共享"(Cross-origin resource sharing)它允许浏览器向跨源服务器,发出 XMLHttpReque ...