Spring-Session with JDBC configuration: Table 'test.spring_session' doesn't exist
<p>I try to run <a href="https://github.com/spring-projects/spring-session/tree/1.2.0.RELEASE//samples/findbyusername" rel="noreferrer">this example</a> but without using Redis, instead with my local MySQL server.</p>

<p>I have edited this spring boot app like this:</p>

<p><strong>Gradle:</strong></p>

<pre><code>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'.
//&gt; 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
}
</code></pre>

<p><strong>application.properties</strong></p>

<pre><code>spring.datasource.url = jdbc:mysql://localhost:3306/TEST?characterEncoding=UTF-8&amp;useUnicode=true&amp;useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;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
</code></pre>

<p><strong>HttpSessionConfig.java</strong></p>

<pre><code>@EnableJdbcHttpSession // &lt;1&gt;
public class HttpSessionConfig {
}
</code></pre>

<p>Application starts on tomcat but when I hit <em>localhost</em> in my browser I get: </p>

<pre><code>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
</code></pre>

<p>I don't remember reading anything about manually creating this table so I assumed that spring will handle it for me...</p>

<p>EDIT:
I actually tried to <a href="http://docs.spring.io/spring-session/docs/current/reference/html5/#api-jdbcoperationssessionrepository-storage" rel="noreferrer">manually create tables</a> and then application runs OK. But I guess I shouldn't be doing this manually.</p>