Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove ‘readOnly’ marker from transaction definition.
yml configuration:
# 服务器配置
server:
port: 8080
session:
timeout: 30
tomcat:
uri-encoding: UTF-8
max-threads: 1000
context-path: /lemon
# spring 数据源配置
spring:
datasource:
# 主数据源
url: jdbc:mysql://localhost:3306/lemon_2?characterEncoding=utf8&useSSL=true
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver
# 配置dbcp 连接池属性
type: org.apache.commons.dbcp2.BasicDataSource
dbcp2:
initial-size: 5
min-idle: 5
max-wait-millis: 60000
max-total: 30
time-between-eviction-runs-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
pool-prepared-statements: true
max-open-prepared-statements: 20
default-read-only: false
# jpa 配置
jpa:
database: mysql
show-sql: true
generate-ddl: true
hibernate:
ddl-auto: update
naming:
strategy: org.hibernate.cfg.ImprovedNamingStrategy
# connection:
# provider_class: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
# springMVC 配置
mvc:
view:
prefix: /WEB-INF/jsp/
suffix: .jsp
# 编码设置
http:
encoding:
force: true
charset: UTF-8
enabled: true
# aop:
# proxy-target-class: true
# 日志配置文件地址
#logging:
# config: classpath:properties/logback-spring.xml
gradle导包:
apply plugin: ‘war’
apply plugin: ‘java’
apply plugin: ‘idea’
apply plugin: ‘org.springframework.boot’
buildscript {
ext {
springBootVersion = ‘1.5.9.RELEASE’
}
repositories {
mavenCentral()
}
dependencies {
classpath(“org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}”)
}
}
group = ‘com.lemengxiangju.lemon’
version = ‘0.0.1-SNAPSHOT’
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
//configurations {
// providedRuntime
//}
dependencies {
compile(‘org.springframework.boot:spring-boot-starter-data-jpa’) {
exclude module: ‘org.springframework.boot:spring-boot-starter-logging’
}
compile(‘org.springframework.boot:spring-boot-starter-jdbc’) {
exclude module: ‘org.springframework.boot:spring-boot-starter-logging’
}
compile('org.springframework.boot:spring-boot-starter-web') {
exclude module: 'org.springframework.boot:spring-boot-starter-logging'
exclude module: 'org.apache.tomcat:spring-boot-starter-tomcat'
}
compile('mysql:mysql-connector-java')
compile('org.springframework.boot:spring-boot-starter-tomcat')
// jsp 页面配置
// https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
// compile group: ‘javax.servlet’, name: ‘javax.servlet-api’, version: ‘4.0.0’
// https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api
// compile group: ‘javax.servlet.jsp’, name: ‘javax.servlet.jsp-api’, version: ‘2.3.2-b02’
// https://mvnrepository.com/artifact/javax.servlet.jsp.jstl/jstl
// compile group: ‘javax.servlet.jsp.jstl’, name: ‘jstl’, version: ‘1.2’
// 数据库连接池支持包 dbcp2
compile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.2.0'
// 配置tomcat jsp 识别。 jsp解析引擎
compile group: 'org.apache.tomcat', name: 'tomcat-jasper', version: '9.0.2'
// alibaba json包
compile group: 'com.alibaba', name: 'fastjson', version: '1.2.44'
// 微信工具dom4j2支持
compile group: 'org.jdom', name: 'jdom2', version: '2.0.6'
// MD5 BASE64 加密依赖jar包
compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
// https://mvnrepository.com/artifact/junit/junit
// testCompile group: ‘junit’, name: ‘junit’, version: ‘4.12’
// swagger API 文档支持包
// compile group: ‘io.swagger’, name: ‘swagger-annotations’, version: ‘2.0.0-rc2’
compile(“io.springfox:springfox-swagger-ui:2.6.1”)
compile(“io.springfox:springfox-swagger2:2.6.1”)
// compile group: ‘io.swagger’, name: ‘swagger-core’, version: ‘2.0.0-rc2’
// compile group: ‘io.swagger’, name: ‘swagger-parser’, version: ‘2.0.0-rc1’
//
// 加载本地 jar 包
compile fileTree(dir:'libs',include:['*.jar'])
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
}
运行出现 上述错误 未解决!!!!!!
使用jpa。问题遗留有空看看!!!!