Closed
Description
Simple barebones Gradle application runs without problems with gradle bootRun
but fails when ran as jar. Here's a gist with the log.
buildscript {
ext {
//springBootVersion = '1.4.0.BUILD-SNAPSHOT'
springBootVersion = '1.4.0.M2'
}
repositories {
mavenCentral()
// jcenter()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'logistica'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-devtools')
compile('org.springframework.boot:spring-boot-starter-mail')
compile('org.springframework.boot:spring-boot-starter-remote-shell')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity4')
compile("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect")
compile('org.springframework.boot:spring-boot-starter-web')
// compile('org.springframework.boot:spring-boot-starter-undertow')
compile('org.hibernate:hibernate-java8')
runtime('org.postgresql:postgresql')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
bootRun {
addResources = true
}
task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}
This is how I build the jar:
./gradlew clean build
:clean
:compileJava
:processResources
:classes
:findMainClass
:jar
:bootRepackage
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
BUILD SUCCESSFUL
Total time: 5.018 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.13/userguide/gradle_daemon.html
application.properties file:
spring.application.name="Logística"
spring.thymeleaf.cache=false
spring.datasource.url=jdbc:postgresql://localhost/dschulz
spring.datasource.username=dschulz
spring.datasource.password=yadayada
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
main application:
package com.dschulz;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class LogisticaApplication {
public static void main(String[] args) {
SpringApplication.run(LogisticaApplication.class, args);
}
}