I am using application.yml file to configure data source. When I run the jar file, I get the exception.
It works fine if I run project in IntelliJ (run button)
Command I use to build and run jar
./gradlew build -x check
java -jar build/libs/UrlShortener-0.0.1-SNAPSHOT-plain.jar
application.yml
spring:
datasource:
url: jdbc:postgresql://localhost:5332/dbName
username: username
password: password
driverClassName: org.postgresql.Driver
Exception
05:13:50.339 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: Failed to determine a suitable driver class
build.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "3.0.2"
id("io.spring.dependency-management") version "1.1.0"
kotlin("jvm") version "1.7.22"
kotlin("plugin.spring") version "1.7.22"
kotlin("plugin.jpa") version "1.7.22"
}
group = "url.shortener"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_17
repositories {
mavenCentral()
}
tasks.withType<Jar> {
manifest {
attributes["Main-Class"] = "url.shortener.UrlShortenerApplicationKt"
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from({
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
})
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.postgresql:postgresql")
val kotlinxHtmlVersion = "0.8.0"
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:$kotlinxHtmlVersion")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
But if I configure through kotlin, it works
#Configuration
class Config {
#Bean
fun getDataSource(): DataSource {
val dataSourceBuilder = DataSourceBuilder.create()
dataSourceBuilder.driverClassName("org.postgresql.Driver")
dataSourceBuilder.url("jdbc:postgresql://localhost:5332/dbName")
dataSourceBuilder.username("username")
dataSourceBuilder.password("password")
return dataSourceBuilder.build()
}
}
taking out your customisation for jar seems to resolve the issue.
//tasks.withType<Jar> {
// manifest {
// attributes["Main-Class"] = "url.shortener.UrlShortenerApplicationKt"
// }
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// from({
// configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
// })
//
//}
Related
I am unable to properly inject an #Value application property in my Kotlin Spring Boot application. The property as defined in my application.yml file, and subsequently referenced in an additional-spring-configuration-metadata.json file (under resources -> META-INF), is not properly being added to the bean expression context. Using IntelliJ version 2020.2.1, when I hover over the property, I see a Cannot resolve configuration property error. Attempting to run the application (with the configuration property value construction-injected into a class) leads to a Unsatisfied dependency expressed through constructor parameter error.
build.gradle.kts
plugins {
id("org.springframework.boot") version "2.3.3.RELEASE"
id("io.spring.dependency-management") version "1.0.10.RELEASE"
kotlin("jvm") version "1.3.72"
kotlin("plugin.spring") version "1.3.72"
}
group = "com.myProject"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_11
repositories {
mavenCentral()
}
extra["springCloudVersion"] = "Hoxton.SR8"
dependencies {
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
implementation("org.springframework.boot:spring-boot-configuration-processor:2.3.3.RELEASE")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
testImplementation("io.projectreactor:reactor-test")
}
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("com.google.cloud.tools:appengine-gradle-plugin:2.2.0")
}
}
apply(plugin = "com.google.cloud.tools.appengine")
configure<com.google.cloud.tools.gradle.appengine.appyaml.AppEngineAppYamlExtension> {
deploy {
projectId = "my-cloud-project"
version = "GCLOUD_CONFIG"
}
}
dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
}
}
Error Message
Spring error modal
additional-spring-configuration-metadata.json
{
"properties": [
{
"name": "otherApi.baseUrl",
"type": "java.lang.String",
"description": "Description for otherApi.baseUrl."
}
]
}
I've added annotation processing dependencies, invalidated caches and restarted, and played around with Kotlin specific annotation processors (kapt). I've also followed the instructions here: https://www.jetbrains.com/help/idea/annotation-processors-support.html
What am I missing? Any and all help would be appreciated. Thanks!
you need to declare the below as as annoatationProcessor
implementation("org.springframework.boot:spring-boot-configuration-processor:2.3.3.RELEASE")
to
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:2.3.3.RELEASE")
If your application.yml (or application.properties) looks like this:
spring:
datasource:
username: postgres
password: postgres
url: jdbc:postgresql://localhost:5433/company
driver-class-name: org.postgresql.Driver
then try to rewrite each property to full-name format for every property:
spring.datasource.username: postgres
spring.datasource.password: postgres
spring.datasource.url: jdbc:postgresql://localhost:5433/company
spring.datasource.driver-class-name: org.postgresql.Driver
Need help with building an executable jar (that can be run with java -jar app.jar) that can be published to maven local repo (using gradle publishToMavenLocal) for a spring boot project.
With these gradle settings gradle publishToMavenLocal works.
Gradle version is 6.3
Spring boot version is 2.2.6
Kotlin 1.3.71
parent build.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.6.RELEASE")
}
}
plugins {
id("org.springframework.boot") version "2.2.6.RELEASE" apply false
id("io.spring.dependency-management") version "1.0.9.RELEASE" apply false
kotlin("jvm") version "1.3.71" apply false
kotlin("plugin.spring") version "1.3.71" apply false
`maven-publish`
`java-library`
signing
}
allprojects {
group = "com.example.user"
version = "0.0.1-SNAPSHOT"
tasks.withType<JavaCompile> {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
incremental = false
}
}
}
subprojects {
repositories {
mavenLocal()
mavenCentral()
}
apply {
plugin("io.spring.dependency-management")
plugin("maven-publish")
}
}
sub-project build.gradle.kts:
plugins {
id("org.springframework.boot")
id("io.spring.dependency-management")
kotlin("jvm")
kotlin("plugin.spring")
}
val developmentOnly by configurations.creating
configurations {
runtimeClasspath {
extendsFrom(developmentOnly)
}
}
dependencies {
implementation(project(":common"))
implementation(project(":user-models"))
implementation(project(":user-core"))
implementation("org.springframework.boot:spring-boot-starter-webflux") {
exclude(group = "org.springframework.boot", module = "spring-boot-starter-logging")
}
implementation("org.springframework.boot:spring-boot-maven-plugin:2.2.6.RELEASE")
implementation(group = "org.springframework.boot", name = "spring-boot-autoconfigure", version = "2.2.6.RELEASE")
implementation(group = "org.springframework.boot", name = "spring-boot-starter-parent", version = "2.2.6.RELEASE")
implementation("org.springframework.boot:spring-boot-configuration-processor:2.2.6.RELEASE")
implementation("org.projectreactor:reactor-spring:1.0.1.RELEASE")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation(group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.3.5")
implementation(group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-reactor", version = "1.3.5")
implementation(group = "org.springframework.boot", name = "spring-boot-starter-log4j2", version = "2.2.6.RELEASE")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
developmentOnly("org.springframework.boot:spring-boot-devtools")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.jar {
enabled = true
manifest {
attributes["Main-Class"] = "com.subnub.user.service.ServiceApplicationKt"
attributes["Class-Path"] = configurations.compileClasspath.get().map { it.name }.joinToString(" ")
}
from(configurations.compileClasspath.get().map { if(it.isDirectory) it else zipTree(it) })
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
tasks.bootJar {
enabled = false
archiveClassifier.set("application")
mainClassName = "com.example.user.service.ServiceApplicationKt"
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
afterEvaluate {
artifactId = tasks.jar.get().archiveBaseName.get()
}
}
}
}
But the jar that is build with these gradle settings breaks when tried to run
stderr:
➜ example-user git:(master) ✗ java -jar example-service/build/libs/example-service-0.0.1-SNAPSHOT.jar
[INFO ] 2020-04-25 22:18:11.871 [main] ServiceApplicationKt - Starting ServiceApplicationKt on admins-mbp-7 with PID 4663 (/Users/zerocase/personal/startups/example/code/example-user/example-service/build/libs/example-service-0.0.1-SNAPSHOT.jar started by abhishek in /Users/zerocase/personal/startups/example/code/example-user)
[INFO ] 2020-04-25 22:18:11.874 [main] ServiceApplicationKt - No active profile set, falling back to default profiles: default
[ERROR] 2020-04-25 22:18:12.055 [main] SpringApplication - Application run failed
java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
at org.springframework.util.Assert.notEmpty(Assert.java:464) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:173) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getAutoConfigurationEntry(AutoConfigurationImportSelector.java:116) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:396) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:878) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:808) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:779) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:192) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:319) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [example-service-0.0.1-SNAPSHOT.jar:?]
at com.example.user.service.ServiceApplicationKt.main(ServiceApplication.kt:19) [example-service-0.0.1-SNAPSHOT.jar:?]
I've tried the workaround suggested here (https://docs.gradle.org/current/userguide/upgrading_version_6.html#publishing_spring_boot_applications) for publishing bootJar artifact. The jar works fine in this case but,
configurations {
listOf(apiElements, runtimeElements).forEach {
it.get().outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(tasks.jar) }
it.get().outgoing.artifact(tasks.bootJar)
}
}
but then gradle does not allows me to do gradle pTML
➜ example-user git:(master) ✗ gradle pTML
> Task :user-service:publishMavenJavaPublicationToMavenLocal FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':user-service:publishMavenJavaPublicationToMavenLocal'.
> Failed to publish publication 'mavenJava' to repository 'mavenLocal'
> Artifact example-service-0.0.1-SNAPSHOT.jar wasn't produced by this build.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
16 actionable tasks: 3 executed, 13 up-to-date
Figured out the fix, artifact needed to be defined in the the publications scope.
publishing {
publications {
create<MavenPublication>("mavenJava") {
//from(components["java"]) // <-- this is not required
artifact(tasks.bootJar.get()) // <-- this is required
}
}
}
and slight modified configurations scope (ref):
configurations {
listOf(apiElements, runtimeElements).forEach {
// Method #1
val jar by tasks
it.get().outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
// Method #2
it.get().outgoing.artifact(tasks.bootJar)
}
}
Here are some sample implementations of publishing publications.
I fixed the error Artifact ....jar wasn't produced by this build adding the parameter enabled = true to the jar task
jar {
enabled = true
}
I'm new at spring boot with kotlin.
I have error when application start up.
I had been seeking various solutions in the other answers in Stackoverflow.
But no answers gave me no solutions.
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
My application.properties configuration is following.
spring.datasource.url=jdbc:mysql://localhost/db_name
spring.datasource.username=db_user
spring.datasource.password=db_pass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
And build.gradle.kts is following.
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.2.0.RELEASE"
id("io.spring.dependency-management") version "1.0.8.RELEASE"
war
kotlin("jvm") version "1.3.50"
kotlin("plugin.spring") version "1.3.50"
kotlin("plugin.jpa") version "1.3.50"
}
group = "jp.co.blowfish.springboot"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
val developmentOnly by configurations.creating
configurations {
runtimeClasspath {
extendsFrom(developmentOnly)
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
developmentOnly("org.springframework.boot:spring-boot-devtools")
runtimeOnly("mysql:mysql-connector-java")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
I have no idea what is wrong.
It is missing the port of Mysql by default is 3306
spring.datasource.url=jdbc:mysql://localhost:3306/db_name`
or application.properties is in resources folder.
I am working on a reactive spring boot api server. I first wanted to use MVC pattern, but I thought reactor would be a good idea.
So I have deleted all spring dependencies on MVC (I believe).
But spring keeps complaining that I can't use #EnableWebMvc along #EnableWebFlux.
Following is my error log
Caused by: java.lang.IllegalStateException: The Java/XML config for Spring MVC and Spring WebFlux cannot both be enabled, e.g. via #EnableWebMvc and #EnableWebFlux, in the same application.
What possibly could be the problem? I sure did updated my dependencies.
And following is my build.gradle.kts file
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
repositories {
mavenCentral()
}
dependencies {
"classpath"(group = "gradle.plugin.com.palantir.gradle.docker", name = "gradle-docker")
}
}
plugins {
kotlin("plugin.jpa") version "1.3.40"
id("org.springframework.boot") version "2.1.6.RELEASE"
id("io.spring.dependency-management") version "1.0.7.RELEASE"
id("com.palantir.docker") version "0.22.1"
kotlin("jvm") version "1.3.40"
kotlin("plugin.spring") version "1.3.40"
}
group = "com.mycompany"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
val developmentOnly by configurations.creating
configurations {
runtimeClasspath {
extendsFrom(developmentOnly)
}
}
repositories {
mavenCentral()
maven(url = "https://repo.spring.io/snapshot")
maven(url = "https://repo.spring.io/milestone")
}
extra["springCloudVersion"] = "Greenwich.SR1"
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-batch")
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
//reactor
implementation("io.projectreactor:reactor-core")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.data:spring-data-jdbc:1.0.0.r2dbc-SNAPSHOT")
implementation("org.springframework.data:spring-data-r2dbc:1.0.0.M1")
implementation("io.r2dbc:r2dbc-spi:1.0.0.M5")
implementation("io.r2dbc:r2dbc-postgresql:1.0.0.M6")
developmentOnly("org.springframework.boot:spring-boot-devtools")
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
testImplementation("org.springframework.batch:spring-batch-test")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
exclude(group = "junit", module = "junit")
}
}
dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
mavenBom("io.projectreactor:reactor-bom:Bismuth-RELEASE")
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
task<Copy>("unpack") {
dependsOn(tasks.getByName("bootJar"))
from(zipTree(tasks.getByName("bootJar").outputs.files.singleFile))
into("build/dependency")
}
I figured it out by deleting each dependencies I have.
The problem was
implementation("org.springframework.boot:spring-boot-starter-web")
After deleting this, It worked. Maybe above dependency has it's own dependencies on WebMvc but I'm not sure.
Error creating bean with name 'org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.core.env.ConfigurableEnvironment' available: expected at least 1 bean which qualifies as autowire candidate.
Eureka error screenshot
build.gradle
buildscript {
ext {
springBootVersion = '2.0.2.RELEASE'
springCloudVersion = 'Finchley.RC2'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.ragavan'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/milestone" }
}
configurations {
providedRuntime
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-server')
runtime('org.springframework.boot:spring-boot-devtools')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
Application
package com.ragavan.discovery;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
#SpringBootApplication
#EnableEurekaServer
public class DiscoveryServerApplication {
public static void main(String[] args) {
SpringApplication.run(DiscoveryServerApplication.class, args);
}
}
I also faced the same issue :
"No qualifying bean of type'org.springframework.core.env.ConfigurableEnvironment'"
I have used STS + maven in a spring boot project so updating the project with "Force update with snapshot release" will resolve the issue.
Also check if the port is not already in use
In application.properties
spring.application.name=server
server.port=8761
The server will start on port as shown below:
Same issue was coming with 2.1.4.RELEASE also. but it resolved with 2.1.5.RELEASE.