前言
Spring Data JPA为Java持久性API(JPA)提供存储库支持。它简化了需要访问JPA数据源的应用程序的开发。
- 新建项目:
- pom.xml
4.0.0
com.jessie
springboot
0.0.1-SNAPSHOT
war
springboot
Demo project for Spring Boot
org.springframework.boot
spring-boot-starter-parent
2.0.2.RELEASE
UTF-8
UTF-8
1.8
org.springframework.boot
spring-boot-starter-data-jpa
org.springframework.boot
spring-boot-starter-web
mysql
mysql-connector-java
runtime
org.springframework.boot
spring-boot-starter-tomcat
org.springframework.boot
spring-boot-starter-test
test
com.alibaba
druid
1.1.5
io.springfox
springfox-swagger2
2.7.0
io.springfox
springfox-swagger-ui
2.7.0
com.google.guava
guava
23.5-jre
javax.servlet
javax.servlet-api
com.alibaba
fastjson
1.2.36
com.squareup.okhttp3
okhttp
3.9.1
com.github.pagehelper
pagehelper-spring-boot-starter
RELEASE
commons-fileupload
commons-fileupload
1.2.1
commons-io
commons-io
1.4
org.apache.poi
poi
3.15
org.apache.poi
poi-ooxml
3.15
javax.servlet
javax.servlet-api
3.1.0
joda-time
joda-time
2.9.9
org.springframework.boot
spring-boot-maven-plugin
- application.yml
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
jpa:
database: mysql
show-sql: true
generate-ddl: true
# hibernate:
# ddl-auto: validate
server:
tomcat:
max-http-post-size: 0
备注:
hibernate:
ddl-auto: validate
出现报错信息如下:
2018-06-07 10:25:43.878 ERROR 12368 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [hibernate_sequence]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1089) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:859) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at com.jessie.springboot.SpringbootApplication.main(SpringbootApplication.java:19) [classes/:na]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [hibernate_sequence]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:402) ~[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) ~[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1765) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
... 16 common frames omitted
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [hibernate_sequence]
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:121) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:42) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:89) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:68) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:191) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:312) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:892) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) ~[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390) ~[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE]
... 20 common frames omitted
Process finished with exit code 1
- Swagger2配置
引入jar包:
io.springfox
springfox-swagger2
2.7.0
io.springfox
springfox-swagger-ui
2.7.0
com.google.guava
guava
23.5-jre
配置信息:
- Jpa
构建User
package com.jessie.springboot.model;
import javax.persistence.*;
import java.io.Serializable;
/**
* @author guanhuijuan
* @create 2018-06-06 11:11
* @desc User
**/
@Entity
@Table(name = "user")
public class User implements Serializable{
@Id
@GeneratedValue
@Column(name = "id")
private Integer id;
@Column(name = "user_name")
private String userName;
@Column(name = "passwd")
private String passwd;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPasswd() {
return passwd;
}
public void setPasswd(String passwd) {
this.passwd = passwd;
}
}
构建Jpa:
package com.jessie.springboot.jpa;
import com.jessie.springboot.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import java.io.Serializable;
/**
* @author guanhuijuan
* @create 2018-06-06 11:14
* @desc UserJpa
**/
@Repository
public interface UserJpa extends
Serializable,
JpaRepository,
JpaSpecificationExecutor {
/**
* 根据用户名和密码执行登录
*
* @param userName 用户名
* @param passwd 密码
* @return
*/
User findByUserNameAndPasswd(String userName, String passwd);
}
- 搭建各层,运行测试:
controller层:
package com.jessie.springboot.controller;
import com.jessie.springboot.http.HttpResponse;
import com.jessie.springboot.model.User;
import com.jessie.springboot.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author guanhuijuan
* @create 2018-06-06 11:20
* @desc UserController
**/
@RestController
@RequestMapping(value = "/user")
public class UserController {
@Autowired
private UserService userService;
/**
* @Author: guanhuijuan
* @Description: 查看用户列表
* @Date: 2018/6/7_15:03
*/
@ApiOperation(value = "用户登录接口")
@RequestMapping(value = "/get", method = RequestMethod.GET)
@ResponseBody
public HttpResponse> get(){
HttpResponse> response = new HttpResponse<>(0,"操作失败",null);
List users = userService.get();
response.setSuccess(1);
response.setMessage("获取用户列表成功!");
response.setData(users);
return response;
}
}
service层:
package com.jessie.springboot.service;
import com.jessie.springboot.model.User;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author guanhuijuan
* @create 2018-06-06 11:16
* @desc UserService
**/
public interface UserService {
/**
* @Author: guanhuijuan
* @Description: 获取用户列表
* @Date: 2018/6/7_15:06
*/
List get();
}
impl实现层:
package com.jessie.springboot.service.impl;
import com.jessie.springboot.jpa.UserJpa;
import com.jessie.springboot.model.User;
import com.jessie.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author guanhuijuan
* @create 2018-06-06 11:17
* @desc UserServiceImpl
**/
@Service
public class UserServiceImpl implements UserService{
@Autowired
private UserJpa userJpa;
@Override
public List get() {
List users = userJpa.findAll();
return users;
}
}
- 运行项目
"C:\Program Files\Java\jdk1.8.0_121\bin\java" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=64895 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2017.2.5\lib\idea_rt.jar=64896:D:\Program Files\JetBrains\IntelliJ IDEA 2017.2.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_121\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\rt.jar;E:\项目\desk\work\temp\springboot\target\classes;D:\Users\sprivacy\maven\repository\org\springframework\boot\spring-boot-starter-data-jpa\2.0.2.RELEASE\spring-boot-starter-data-jpa-2.0.2.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\boot\spring-boot-starter\2.0.2.RELEASE\spring-boot-starter-2.0.2.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\boot\spring-boot\2.0.2.RELEASE\spring-boot-2.0.2.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.2.RELEASE\spring-boot-autoconfigure-2.0.2.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\boot\spring-boot-starter-logging\2.0.2.RELEASE\spring-boot-starter-logging-2.0.2.RELEASE.jar;D:\Users\sprivacy\maven\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\Users\sprivacy\maven\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\Users\sprivacy\maven\repository\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;D:\Users\sprivacy\maven\repository\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;D:\Users\sprivacy\maven\repository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;D:\Users\sprivacy\maven\repository\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;D:\Users\sprivacy\maven\repository\org\springframework\boot\spring-boot-starter-aop\2.0.2.RELEASE\spring-boot-starter-aop-2.0.2.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\spring-aop\5.0.6.RELEASE\spring-aop-5.0.6.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\aspectj\aspectjweaver\1.8.13\aspectjweaver-1.8.13.jar;D:\Users\sprivacy\maven\repository\org\springframework\boot\spring-boot-starter-jdbc\2.0.2.RELEASE\spring-boot-starter-jdbc-2.0.2.RELEASE.jar;D:\Users\sprivacy\maven\repository\com\zaxxer\HikariCP\2.7.9\HikariCP-2.7.9.jar;D:\Users\sprivacy\maven\repository\org\springframework\spring-jdbc\5.0.6.RELEASE\spring-jdbc-5.0.6.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\hibernate\hibernate-core\5.2.17.Final\hibernate-core-5.2.17.Final.jar;D:\Users\sprivacy\maven\repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;D:\Users\sprivacy\maven\repository\org\hibernate\javax\persistence\hibernate-jpa-2.1-api\1.0.0.Final\hibernate-jpa-2.1-api-1.0.0.Final.jar;D:\Users\sprivacy\maven\repository\org\javassist\javassist\3.22.0-GA\javassist-3.22.0-GA.jar;D:\Users\sprivacy\maven\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;D:\Users\sprivacy\maven\repository\org\jboss\jandex\2.0.3.Final\jandex-2.0.3.Final.jar;D:\Users\sprivacy\maven\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;D:\Users\sprivacy\maven\repository\org\hibernate\common\hibernate-commons-annotations\5.0.1.Final\hibernate-commons-annotations-5.0.1.Final.jar;D:\Users\sprivacy\maven\repository\javax\transaction\javax.transaction-api\1.2\javax.transaction-api-1.2.jar;D:\Users\sprivacy\maven\repository\org\springframework\data\spring-data-jpa\2.0.7.RELEASE\spring-data-jpa-2.0.7.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\data\spring-data-commons\2.0.7.RELEASE\spring-data-commons-2.0.7.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\spring-orm\5.0.6.RELEASE\spring-orm-5.0.6.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\spring-context\5.0.6.RELEASE\spring-context-5.0.6.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\spring-tx\5.0.6.RELEASE\spring-tx-5.0.6.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\spring-beans\5.0.6.RELEASE\spring-beans-5.0.6.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\spring-aspects\5.0.6.RELEASE\spring-aspects-5.0.6.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\boot\spring-boot-starter-web\2.0.2.RELEASE\spring-boot-starter-web-2.0.2.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\boot\spring-boot-starter-json\2.0.2.RELEASE\spring-boot-starter-json-2.0.2.RELEASE.jar;D:\Users\sprivacy\maven\repository\com\fasterxml\jackson\core\jackson-databind\2.9.5\jackson-databind-2.9.5.jar;D:\Users\sprivacy\maven\repository\com\fasterxml\jackson\core\jackson-core\2.9.5\jackson-core-2.9.5.jar;D:\Users\sprivacy\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.5\jackson-datatype-jdk8-2.9.5.jar;D:\Users\sprivacy\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.5\jackson-datatype-jsr310-2.9.5.jar;D:\Users\sprivacy\maven\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.5\jackson-module-parameter-names-2.9.5.jar;D:\Users\sprivacy\maven\repository\org\hibernate\validator\hibernate-validator\6.0.9.Final\hibernate-validator-6.0.9.Final.jar;D:\Users\sprivacy\maven\repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;D:\Users\sprivacy\maven\repository\org\springframework\spring-web\5.0.6.RELEASE\spring-web-5.0.6.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\spring-webmvc\5.0.6.RELEASE\spring-webmvc-5.0.6.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\spring-expression\5.0.6.RELEASE\spring-expression-5.0.6.RELEASE.jar;D:\Users\sprivacy\maven\repository\mysql\mysql-connector-java\5.1.46\mysql-connector-java-5.1.46.jar;D:\Users\sprivacy\maven\repository\org\springframework\boot\spring-boot-starter-tomcat\2.0.2.RELEASE\spring-boot-starter-tomcat-2.0.2.RELEASE.jar;D:\Users\sprivacy\maven\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;D:\Users\sprivacy\maven\repository\org\apache\tomcat\embed\tomcat-embed-core\8.5.31\tomcat-embed-core-8.5.31.jar;D:\Users\sprivacy\maven\repository\org\apache\tomcat\embed\tomcat-embed-el\8.5.31\tomcat-embed-el-8.5.31.jar;D:\Users\sprivacy\maven\repository\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.31\tomcat-embed-websocket-8.5.31.jar;D:\Users\sprivacy\maven\repository\net\bytebuddy\byte-buddy\1.7.11\byte-buddy-1.7.11.jar;D:\Users\sprivacy\maven\repository\org\springframework\spring-core\5.0.6.RELEASE\spring-core-5.0.6.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\spring-jcl\5.0.6.RELEASE\spring-jcl-5.0.6.RELEASE.jar;D:\Users\sprivacy\maven\repository\com\alibaba\druid\1.1.5\druid-1.1.5.jar;D:\Users\sprivacy\maven\repository\io\springfox\springfox-swagger2\2.7.0\springfox-swagger2-2.7.0.jar;D:\Users\sprivacy\maven\repository\io\swagger\swagger-annotations\1.5.13\swagger-annotations-1.5.13.jar;D:\Users\sprivacy\maven\repository\io\swagger\swagger-models\1.5.13\swagger-models-1.5.13.jar;D:\Users\sprivacy\maven\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;D:\Users\sprivacy\maven\repository\io\springfox\springfox-spi\2.7.0\springfox-spi-2.7.0.jar;D:\Users\sprivacy\maven\repository\io\springfox\springfox-core\2.7.0\springfox-core-2.7.0.jar;D:\Users\sprivacy\maven\repository\io\springfox\springfox-schema\2.7.0\springfox-schema-2.7.0.jar;D:\Users\sprivacy\maven\repository\io\springfox\springfox-swagger-common\2.7.0\springfox-swagger-common-2.7.0.jar;D:\Users\sprivacy\maven\repository\io\springfox\springfox-spring-web\2.7.0\springfox-spring-web-2.7.0.jar;D:\Users\sprivacy\maven\repository\org\reflections\reflections\0.9.11\reflections-0.9.11.jar;D:\Users\sprivacy\maven\repository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;D:\Users\sprivacy\maven\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;D:\Users\sprivacy\maven\repository\org\springframework\plugin\spring-plugin-core\1.2.0.RELEASE\spring-plugin-core-1.2.0.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\springframework\plugin\spring-plugin-metadata\1.2.0.RELEASE\spring-plugin-metadata-1.2.0.RELEASE.jar;D:\Users\sprivacy\maven\repository\org\mapstruct\mapstruct\1.1.0.Final\mapstruct-1.1.0.Final.jar;D:\Users\sprivacy\maven\repository\io\springfox\springfox-swagger-ui\2.7.0\springfox-swagger-ui-2.7.0.jar;D:\Users\sprivacy\maven\repository\com\google\guava\guava\23.5-jre\guava-23.5-jre.jar;D:\Users\sprivacy\maven\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;D:\Users\sprivacy\maven\repository\org\checkerframework\checker-qual\2.0.0\checker-qual-2.0.0.jar;D:\Users\sprivacy\maven\repository\com\google\errorprone\error_prone_annotations\2.0.18\error_prone_annotations-2.0.18.jar;D:\Users\sprivacy\maven\repository\com\google\j2objc\j2objc-annotations\1.1\j2objc-annotations-1.1.jar;D:\Users\sprivacy\maven\repository\org\codehaus\mojo\animal-sniffer-annotations\1.14\animal-sniffer-annotations-1.14.jar;D:\Users\sprivacy\maven\repository\javax\servlet\javax.servlet-api\3.1.0\javax.servlet-api-3.1.0.jar;D:\Users\sprivacy\maven\repository\com\alibaba\fastjson\1.2.36\fastjson-1.2.36.jar;D:\Users\sprivacy\maven\repository\com\squareup\okhttp3\okhttp\3.9.1\okhttp-3.9.1.jar;D:\Users\sprivacy\maven\repository\com\squareup\okio\okio\1.13.0\okio-1.13.0.jar;D:\Users\sprivacy\maven\repository\com\github\pagehelper\pagehelper-spring-boot-starter\1.2.5\pagehelper-spring-boot-starter-1.2.5.jar;D:\Users\sprivacy\maven\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\1.3.2\mybatis-spring-boot-starter-1.3.2.jar;D:\Users\sprivacy\maven\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\1.3.2\mybatis-spring-boot-autoconfigure-1.3.2.jar;D:\Users\sprivacy\maven\repository\org\mybatis\mybatis\3.4.6\mybatis-3.4.6.jar;D:\Users\sprivacy\maven\repository\org\mybatis\mybatis-spring\1.3.2\mybatis-spring-1.3.2.jar;D:\Users\sprivacy\maven\repository\com\github\pagehelper\pagehelper-spring-boot-autoconfigure\1.2.5\pagehelper-spring-boot-autoconfigure-1.2.5.jar;D:\Users\sprivacy\maven\repository\com\github\pagehelper\pagehelper\5.1.4\pagehelper-5.1.4.jar;D:\Users\sprivacy\maven\repository\com\github\jsqlparser\jsqlparser\1.0\jsqlparser-1.0.jar;D:\Users\sprivacy\maven\repository\commons-fileupload\commons-fileupload\1.2.1\commons-fileupload-1.2.1.jar;D:\Users\sprivacy\maven\repository\commons-io\commons-io\1.4\commons-io-1.4.jar;D:\Users\sprivacy\maven\repository\org\apache\poi\poi\3.15\poi-3.15.jar;D:\Users\sprivacy\maven\repository\commons-codec\commons-codec\1.11\commons-codec-1.11.jar;D:\Users\sprivacy\maven\repository\org\apache\commons\commons-collections4\4.1\commons-collections4-4.1.jar;D:\Users\sprivacy\maven\repository\org\apache\poi\poi-ooxml\3.15\poi-ooxml-3.15.jar;D:\Users\sprivacy\maven\repository\org\apache\poi\poi-ooxml-schemas\3.15\poi-ooxml-schemas-3.15.jar;D:\Users\sprivacy\maven\repository\org\apache\xmlbeans\xmlbeans\2.6.0\xmlbeans-2.6.0.jar;D:\Users\sprivacy\maven\repository\stax\stax-api\1.0.1\stax-api-1.0.1.jar;D:\Users\sprivacy\maven\repository\com\github\virtuald\curvesapi\1.04\curvesapi-1.04.jar;D:\Users\sprivacy\maven\repository\joda-time\joda-time\2.9.9\joda-time-2.9.9.jar" com.jessie.springboot.SpringbootApplication
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.2.RELEASE)
2018-06-07 15:13:19.069 INFO 16584 --- [ main] c.j.springboot.SpringbootApplication : Starting SpringbootApplication on DESKTOP-NJBV58A with PID 16584 (started by sprivacy in E:\项目\desk\work\temp\springboot)
2018-06-07 15:13:19.071 INFO 16584 --- [ main] c.j.springboot.SpringbootApplication : No active profile set, falling back to default profiles: default
2018-06-07 15:13:19.113 INFO 16584 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5c33f1a9: startup date [Thu Jun 07 15:13:19 CST 2018]; root of context hierarchy
2018-06-07 15:13:19.840 WARN 16584 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.jessie.springboot]' package. Please check your configuration.
2018-06-07 15:13:20.252 INFO 16584 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$4539212d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-06-07 15:13:20.492 INFO 16584 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-06-07 15:13:20.509 INFO 16584 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-06-07 15:13:20.509 INFO 16584 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-06-07 15:13:20.513 INFO 16584 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_121\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:\python35;D:\python35\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Java\jdk1.8.0_111\bin;C:\Program Files\Java\jdk1.8.0_121\bin;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;D:\Users\sprivacy\maven\apache-maven-3.5.0\bin;D:\Program Files\TortoiseSVN\bin;D:\BaiduNetdiskDownload\Git\cmd;D:\ghj。\node\;C:\WINDOWS\System32\OpenSSH\;D:\python35\Scripts\;D:\python35\;C:\Users\sprivacy\AppData\Local\Microsoft\WindowsApps;C:\Users\sprivacy\AppData\Local\GitHubDesktop\bin;C:\Users\sprivacy\AppData\Roaming\npm;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;;.]
2018-06-07 15:13:20.614 INFO 16584 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-06-07 15:13:20.614 INFO 16584 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1508 ms
2018-06-07 15:13:20.727 INFO 16584 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-06-07 15:13:20.733 INFO 16584 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-06-07 15:13:20.733 INFO 16584 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-06-07 15:13:20.734 INFO 16584 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-06-07 15:13:20.734 INFO 16584 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-06-07 15:13:20.734 INFO 16584 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'corsFilter' to: [/*]
2018-06-07 15:13:20.917 INFO 16584 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited
Thu Jun 07 15:13:21 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2018-06-07 15:13:21.121 INFO 16584 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-06-07 15:13:21.129 INFO 16584 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-06-07 15:13:21.174 INFO 16584 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2018-06-07 15:13:21.175 INFO 16584 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-06-07 15:13:21.198 INFO 16584 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-06-07 15:13:21.275 INFO 16584 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2018-06-07 15:13:21.582 INFO 16584 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-06-07 15:13:22.022 WARN 16584 --- [ main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2018-06-07 15:13:22.069 INFO 16584 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/user/get],methods=[GET]}" onto public com.jessie.springboot.http.HttpResponse> com.jessie.springboot.controller.UserController.get()
2018-06-07 15:13:22.071 INFO 16584 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/user/login],methods=[POST]}" onto public com.jessie.springboot.http.HttpResponse com.jessie.springboot.controller.UserController.login(com.jessie.springboot.model.User)
2018-06-07 15:13:22.073 INFO 16584 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources/configuration/ui]}" onto public org.springframework.http.ResponseEntity springfox.documentation.swagger.web.ApiResourceController.uiConfiguration()
2018-06-07 15:13:22.074 INFO 16584 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources]}" onto public org.springframework.http.ResponseEntity> springfox.documentation.swagger.web.ApiResourceController.swaggerResources()
2018-06-07 15:13:22.074 INFO 16584 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources/configuration/security]}" onto public org.springframework.http.ResponseEntity springfox.documentation.swagger.web.ApiResourceController.securityConfiguration()
2018-06-07 15:13:22.076 INFO 16584 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-06-07 15:13:22.077 INFO 16584 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-06-07 15:13:22.187 INFO 16584 --- [ main] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [public org.springframework.http.ResponseEntity springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)]
2018-06-07 15:13:22.274 INFO 16584 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-06-07 15:13:22.400 INFO 16584 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5c33f1a9: startup date [Thu Jun 07 15:13:19 CST 2018]; root of context hierarchy
2018-06-07 15:13:22.432 INFO 16584 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-06-07 15:13:22.432 INFO 16584 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-06-07 15:13:22.686 INFO 16584 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-06-07 15:13:22.688 INFO 16584 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-06-07 15:13:22.691 INFO 16584 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.alibaba.druid.pool:name=dataSource,type=DruidDataSource]
2018-06-07 15:13:22.694 INFO 16584 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483647
2018-06-07 15:13:22.695 INFO 16584 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2018-06-07 15:13:22.708 INFO 16584 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2018-06-07 15:13:22.731 INFO 16584 --- [ main] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
2018-06-07 15:13:22.863 INFO 16584 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-06-07 15:13:22.866 INFO 16584 --- [ main] c.j.springboot.SpringbootApplication : Started SpringbootApplication in 4.125 seconds (JVM running for 4.873)
成功运行!
打开Swagger:
http://192.168.1.102:8080/swagger-ui.html#/
如图所示:
获取用户列表:
- 总结:
以上就是springboot,over。