springboot简单项目
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:
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
pom.xml文件的依赖添加
<?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>com.baizhi.springboot.fo</groupId>
<artifactId>FoWang</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>FoWang Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!--springboot对web的支持的依赖-->
<!-- https:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
<!--tomcat的依赖-->
<!-- https:
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>9.0.16</version>
</dependency>
<!--jsp的依赖-->
<!-- https:
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!--对maven的依赖-->
<!-- https:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
<!---mybatis的依赖-->
<!-- https:
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<!--对数据源的依赖-->
<!-- https:
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<!--对mysql的依赖-->
<!-- https:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<!--测试的依赖-->
<!-- https:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.1.3.RELEASE</version>
<scope>test</scope>
</dependency>
<!--加这个依赖的目的是因为使用的验证码用到该依赖-->
<!-- https:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!--文件上传依赖-->
<!-- https:
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<!--验证码依赖-->
<dependency>
<groupId>com</groupId>
<artifactId>patchca</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com</groupId>
<artifactId>jstl</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jstl-impl</artifactId>
<version>1.2</version>
</dependency>
<!--Excel相关-->
<!-- https:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<!--easypoi相关-->
<!-- https:
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>4.0.0</version>
</dependency>
<!-- https:
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.2</version>
</dependency>
<!--Redis缓存依赖-->
<!-- https:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
</dependencies>
<build>
<finalName>FoWang</finalName>
<plugins>
<plugin><!--修改服务器-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin> <!--maven配置-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.3.RELEASE</version>
</plugin>
</plugins>
</build>
</project>
需要在根基包同级写启动类
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
@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);
}
|