mysql jdbc 找不到表_mysql – 使用JDBC配置的Spring-Session:表’test.spring_session’不存在...

我尝试运行

this example但不使用Redis,而是使用我的本地MySQL服务器.

我编辑了这个春季启动应用程序,如下所示:

摇篮:

buildscript {

repositories {

mavenCentral()

}

dependencies {

classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion")

}

}

apply plugin: 'spring-boot'

apply from: JAVA_GRADLE

//this 'if' statement is because I was getting error: Execution failed for task ':samples:findbyusername:findMainClass'.

//> Could not find property 'main' on task ':samples:findbyusername:run'.

if (!hasProperty('mainClass')) {

ext.mainClass = 'sample.FindByUsernameApplication'

}

tasks.findByPath("artifactoryPublish")?.enabled = false

group = 'samples'

dependencies {

compile("org.springframework.boot:spring-boot-starter-jdbc:$springBootVersion")

compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.2'

compile group: 'org.springframework.session', name: 'spring-session', version: '1.2.0.RELEASE'

compile project(':spring-session'),

"org.springframework.boot:spring-boot-starter-web",

"org.springframework.boot:spring-boot-starter-thymeleaf",

"nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect",

"org.springframework.security:spring-security-web:$springSecurityVersion",

"org.springframework.security:spring-security-config:$springSecurityVersion",

"com.maxmind.geoip2:geoip2:2.3.1",

"org.apache.httpcomponents:httpclient"

testCompile "org.springframework.boot:spring-boot-starter-test",

"org.assertj:assertj-core:$assertjVersion"

integrationTestCompile gebDependencies,

"org.spockframework:spock-spring:$spockVersion"

}

def reservePort() {

def socket = new ServerSocket(0)

def result = socket.localPort

socket.close()

result

}

application.properties

spring.datasource.url = jdbc:mysql://localhost:3306/TEST?characterEncoding=UTF-8&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

spring.datasource.driverClassName = com.mysql.jdbc.Driver

spring.datasource.username=root

spring.datasource.password=but

spring.thymeleaf.cache=false

spring.template.cache=false

HttpSessionConfig.java

@EnableJdbcHttpSession // <1>

public class HttpSessionConfig {

}

应用程序从tomcat开始,但是当我在浏览器中点击localhost时,我得到:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Mon May 23 21:14:31 CEST 2016

There was an unexpected error (type=Internal Server Error, status=500).

PreparedStatementCallback; bad SQL grammar [INSERT INTO SPRING_SESSION(SESSION_ID, CREATION_TIME, LAST_ACCESS_TIME, MAX_INACTIVE_INTERVAL, PRINCIPAL_NAME) VALUES (?, ?, ?, ?, ?)]; nested exception is java.sql.SQLSyntaxErrorException: Table 'test.spring_session' doesn't exist

我不记得读过关于手动创建这个表的任何内容所以我认为spring会为我处理它…

编辑:

我实际上尝试了manually create tables,然后应用程序运行正常.但我想我不应该手动这样做.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值