1

I have setup spring boot project on windows machine. Configuration: Windows 10 | Java 8 implementation 'org.springframework.boot:spring-boot-starter-data-jpa' With this plugin I am getting error

Execution failed for task ':DemoApplication.main()'.
> Process 'command 'C:/Program Files/Java/jdk1.8.0_231/bin/java.exe'' finished with non-zero exit value 1

Tried googling the problem but no luck.

Issue only with that plugin if the same removed its works fine.

plugins {
id 'org.springframework.boot' version '2.3.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
  mavenCentral()
}

dependencies {
  implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
  implementation 'org.springframework.boot:spring-boot-starter-web'
 testImplementation('org.springframework.boot:spring-boot-starter-test') {
    exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
  }
 }

 test {
  useJUnitPlatform()
  }
prashant.fepale
  • 547
  • 1
  • 8
  • 26
  • Maybe it is an [issue with the different versions](https://stackoverflow.com/questions/49210354/execution-failed-for-task-bootrun-process-command-c-program-files-java), but without more details, it is difficult to help. Otherwise I can also recommend the [Spring Initializr](https://start.spring.io/). – flaxel Oct 01 '20 at 18:19
  • @flaxel No problem with version and the same created from Spring Initializr. I m also not getting more details than this and same project working fine on Mac. Problem is with windows only. – prashant.fepale Oct 01 '20 at 18:30
  • But maybe you can post more of your project like the `pom.xml` file. – flaxel Oct 01 '20 at 18:32
  • build.gradle added – prashant.fepale Oct 01 '20 at 18:37
  • Can you run the app with the logging level set to DEBUG and post the logs? – dextertron_ Oct 01 '20 at 20:20
  • Just to clarify. Are you talking about `plugins` section or `dependencies` in `build.gradle`. – wak786 Oct 04 '20 at 12:37

2 Answers2

1

I created a project from spring initializr on my local with dependencies same as defined in your build.gradle.

Here is what i found :-

1. I tried to run the application but it failed. After going through logs it seems that spring is trying to initialize beans for data layer (which is expected as we are adding starter-jpa) but since we don't have any database configured it is failing.

2. I added a embedded h2 database dependency (do gradle refresh if auto import not enabled). Then i restarted the server and it was working fine. If you dont want to go with embedded db you can configure the one you are using. Below is my build.gradle.

plugins {
    id 'org.springframework.boot' version '2.3.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    // https://mvnrepository.com/artifact/com.h2database/h2
    implementation group: 'com.h2database', name: 'h2', version: '1.3.148'

    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

test {
    useJUnitPlatform()
}

wak786
  • 1,562
  • 1
  • 8
  • 12
0

Ok so this seems to compile once you have defined in your application.properties

spring.datasource.url=url
spring.datasource.username=user
spring.datasource.password=pass

I'm not sure why this is now only a issue for me, as i said in a comment which was deleted (fairly I might add), I've another project with the dependancy listed but not configured (db settings) and it compiles without issue.

Anyway, give that ago and let me know if it works. If not I'll have another play around and see if I can help you.

MetaCoder
  • 368
  • 5
  • 22