Answer the question
In order to leave comments, you need to log in
How to fix error when running Spring on combat machine?
Good day.
I run the Jar file from the terminal (added to autoload scripts on Ubuntu Server). But after a while the site stops working and gives an error
Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.TransactionException: JDBC begin transaction failed:
group 'ru.test'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.0.3'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.6.RELEASE")
classpath 'mysql:mysql-connector-java:5.1.34'
}
}
apply plugin: 'kotlin'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'test'
version = '0.1.0'
}
springBoot {
mainClass = 'ru.test.Application'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
// Kotlin
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// Spring
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
// Others
compile("org.hibernate:hibernate-validator")
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
compile 'mysql:mysql-connector-java:5.1.31'
compile 'commons-dbcp:commons-dbcp:1.4'
// Tests
testCompile("org.springframework:spring-test")
testCompile("junit:junit")
testCompile 'org.springframework.security:spring-security-test'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
jar {
manifest {
attributes 'Main-Class': 'ru.test.Application'
attributes 'Class-Path': configurations.compile.collect { "lib/" + it.getName() }.join(' ')
}
into('lib') {
from configurations.compile
}
}
task copyDependencies(type: Copy) {
into "$libsDir/lib"
from configurations.compile
}
build.doLast {
tasks.copyDependencies.execute()
}
# Settings site
server.port=80
# Settings for database
spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=yes&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=password
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.enable_lazy_load_no_trans = true
@SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
@Configuration
@EnableJpaRepositories(basePackages = arrayOf("ru.test.repositories"))
open class Application {
companion object {
@JvmStatic fun main(args: Array<String>) {
SpringApplication.run(Application::class.java, *args)
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question