springboot的yml(application.yml)
server:
port: 9002
servlet:
jsp:
init-parameters:
development: true
spring:
mvc:
view:
prefix: /
suffix: .jsp
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/fowang?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
username: root
password: 123456
type: org.apache.commons.dbcp.BasicDataSource
jackson:
date-format: yyyy-MM-dd
time-zone: GMT+8
mybatis:
mapper-locations: classpath:/com.baizhi.fo/*DaoMapper.xml
type-aliases-package: com.baizhi.fo.entity
pom.xml文件的依赖添加
4.0.0 com.baizhi.springboot.fo FoWang 1.0-SNAPSHOT war FoWang Maven Webapp http://www.example.com UTF-8 1.7 1.7 junit junit 4.12 test org.springframework.boot spring-boot-starter-web 2.1.3.RELEASE org.apache.tomcat.embed tomcat-embed-jasper 9.0.16 javax.servlet.jsp.jstl jstl 1.2 org.springframework.boot spring-boot-maven-plugin 2.1.3.RELEASE org.mybatis.spring.boot mybatis-spring-boot-starter 1.3.2 commons-dbcp commons-dbcp 1.4 mysql mysql-connector-java 5.1.38 org.springframework.boot spring-boot-starter-test 2.1.3.RELEASE test javax.servlet javax.servlet-api 3.1.0 provided commons-fileupload commons-fileupload 1.3.1 com patchca 1.0.0 com jstl 1.0.0 org.glassfish.web jstl-impl 1.2 org.apache.poi poi 3.17 cn.afterturn easypoi-annotation 4.0.0 cn.afterturn easypoi-web 4.0.0 org.aspectj aspectjweaver 1.9.2 org.springframework.boot spring-boot-starter-data-redis 2.1.3.RELEASE FoWang org.apache.maven.plugins maven-compiler-plugin 3.7.0 1.8 1.8 org.springframework.boot spring-boot-maven-plugin 2.1.3.RELEASE
需要在根基包同级写启动类
package com.baizhi.fo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
@SpringBootApplication
//添加扫描文件(dao/过滤器(拦截器等))
@MapperScan("com.baizhi.fo.dao")
(过滤器)
public class Application {
public static void main(String[] args) { SpringApplication.run(Application.class,args);
}
}
mapper相关内容同另一博文(ssm项目)
简单controller写法
@Controller
public class AlbumController {
@Autowired
private AlbumService albumService;
//条件分页
@RequestMapping("/showpageAlbums")
@ResponseBody
public Map selectPagesByConditions(Integer page,Integer limit,String albumname){
return albumService.selectPageAlbums(page,limit,albumname);
}



