R2dbc and Jdbc Probelm Spring Boot - spring-boot

Hi everyone I wrote a rest api using Spring Boot Webflux
LabelController
#RestController
#RequestMapping("/api/label")
#RequiredArgsConstructor
public class LabelController {
private final LabelService labelService;
#GetMapping
public Flux<LabelEntity> getAllLabels(){
return labelService.getAll();
}
LabelService
#Service
#RequiredArgsConstructor
public class LabelService {
private final LabelRepository labelRepository;
public Flux<LabelEntity> getAll() {
return labelRepository.findAll();
}
LabelRespository
#Repository
public interface LabelRepository extends ReactiveCrudRepository<LabelEntity,Integer> {
}
Application.yml
Since I use liquebase in the application yml part, I added jdbc and r2dbc.
spring:
liquibase:
enabled: true
url: jdbc:postgresql://localhost:5432/liquebase
user: postgres
password: 12345
change-log: classpath:db/liquibase/db.changelog-master-main.yml
datasource:
driver-class-name: org.postgresql.Driver
r2dbc:
url: r2dbc:postgresql://localhost:5432/liquebase
username: postgres
password: 12345
pool:
initial-size: 100
max-size: 500
max-idle-time: 30m
validation-query: SELECT 1
server:
port: 8085
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.WebFluxTestCodes</groupId>
<artifactId>WebFluxTestCodes</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>WebFluxTestCodes</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-r2dbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.10.3</version>
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
My RestApi Main Class
#SpringBootApplication
#EnableR2dbcRepositories
#ComponentScan("com.WebFluxTestCodes.WebFluxTestCodes.business.*")
public class WebFluxTestCodesApplication {
public static void main(String[] args) {
SpringApplication.run(WebFluxTestCodesApplication.class, args);
}
}
Log my project not problem in project is started
2021-03-15 20:38:12.375 INFO 8692 --- [ restartedMain] c.W.W.WebFluxTestCodesApplication :
Starting WebFluxTestCodesApplication using Java 15.0.1 on WIN-3QMQSJHKUBK with PID 8692
(C:\Users\user\Desktop\TestWebService\WebFluxTestCodes\target\classes started by user in
C:\Users\user\Desktop\TestWebService\WebFluxTestCodes)
2021-03-15 20:38:12.375 INFO 8692 --- [ restartedMain] c.W.W.WebFluxTestCodesApplication :
No active profile set, falling back to default profiles: default
2021-03-15 20:38:13.266 INFO 8692 --- [ restartedMain] o.s.b.devtools.restart.ChangeableUrls :
The Class-Path manifest attribute in C:\Users\user\.m2\repository\org\liquibase\liquibase-
core\3.10.3\liquibase-core-3.10.3.jar referenced one or more files that do not exist:
file:/C:/Users/user/.m2/repository/org/liquibase/liquibase-core/3.10.3/commons-cli-
1.4.jar,file:/C:/Users/user/.m2/repository/org/liquibase/liquibase-core/3.10.3/snakeyaml-
1.24.jar,file:/C:/Users/user/.m2/repository/org/liquibase/liquibase-core/3.10.3/slf4j-api-
1.7.28.jar,file:/C:/Users/user/.m2/repository/org/liquibase/liquibase-core/3.10.3/logback-classic-
1.2.3.jar,file:/C:/Users/user/.m2/repository/org/liquibase/liquibase-core/3.10.3/logback-core-
1.2.3.jar
2021-03-15 20:38:13.266 INFO 8692 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor :
Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2021-03-15 20:38:13.266 INFO 8692 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor :
For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2021-03-15 20:38:16.782 INFO 8692 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate :
Multiple Spring Data modules found, entering strict repository configuration mode!
2021-03-15 20:38:16.782 INFO 8692 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate
: Bootstrapping Spring Data R2DBC repositories in DEFAULT mode.
2021-03-15 20:38:17.264 INFO 8692 --- [ restartedMain] .RepositoryConfigurationExtensionSupport
: Spring Data R2DBC - Could not safely identify store assignment for repository candidate
interface com.WebFluxTestCodes.WebFluxTestCodes.repository.LabelRepository. If you want this
repository to be a R2DBC repository, consider annotating your entities with one of these
annotations: org.springframework.data.relational.core.mapping.Table (preferred), or consider
extending one of the following types with your repository:
org.springframework.data.r2dbc.repository.R2dbcRepository.
2021-03-15 20:38:17.276 INFO 8692 --- [ restartedMain]
.RepositoryConfigurationExtensionSupport : Spring Data R2DBC - Could not safely identify store
assignment for repository candidate interface
com.WebFluxTestCodes.WebFluxTestCodes.repository.ProjectRepository. If you want this repository
to be a R2DBC repository, consider annotating your entities with one of these annotations:
org.springframework.data.relational.core.mapping.Table (preferred), or consider extending one of
the following types with your repository:
org.springframework.data.r2dbc.repository.R2dbcRepository.
2021-03-15 20:38:17.280 INFO 8692 --- [ restartedMain] .RepositoryConfigurationExtensionSupport
: Spring Data R2DBC - Could not safely identify store assignment for repository candidate
interface com.WebFluxTestCodes.WebFluxTestCodes.repository.TasksRepository. If you want this
repository to be a R2DBC repository, consider annotating your entities with one of these
annotations: org.springframework.data.relational.core.mapping.Table (preferred), or consider
extending one of the following types with your repository:
org.springframework.data.r2dbc.repository.R2dbcRepository.
2021-03-15 20:38:17.284 INFO 8692 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate
: Finished Spring Data repository scanning in 452 ms. Found 0 R2DBC repository interfaces.
2021-03-15 20:38:18.522 INFO 8692 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate
: Multiple Spring Data modules found, entering strict repository configuration mode!
2021-03-15 20:38:18.624 INFO 8692 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate
: Bootstrapping Spring Data R2DBC repositories in DEFAULT mode.
2021-03-15 20:38:18.714 INFO 8692 --- [ restartedMain] .RepositoryConfigurationExtensionSupport
: Spring Data R2DBC - Could not safely identify store assignment for repository candidate
interface com.WebFluxTestCodes.WebFluxTestCodes.repository.LabelRepository. If you want this
repository to be a R2DBC repository, consider annotating your entities with one of these
annotations: org.springframework.data.relational.core.mapping.Table (preferred), or consider
extending one of the following types with your repository:
org.springframework.data.r2dbc.repository.R2dbcRepository.
2021-03-15 20:38:18.718 INFO 8692 --- [ restartedMain]
.RepositoryConfigurationExtensionSupport : Spring Data R2DBC - Could not safely identify store
assignment for repository candidate interface
com.WebFluxTestCodes.WebFluxTestCodes.repository.ProjectRepository. If you want this repository
to be a R2DBC repository, consider annotating your entities with one of these annotations:
org.springframework.data.relational.core.mapping.Table (preferred), or consider extending one
of the following types with your repository:
org.springframework.data.r2dbc.repository.R2dbcRepository.
2021-03-15 20:38:18.723 INFO 8692 --- [ restartedMain] .RepositoryConfigurationExtensionSupport
: Spring Data R2DBC - Could not safely identify store assignment for repository candidate
interface com.WebFluxTestCodes.WebFluxTestCodes.repository.TasksRepository. If you want this
repository to be a R2DBC repository, consider annotating your entities with one of these
annotations: org.springframework.data.relational.core.mapping.Table (preferred), or consider
extending one of the following types with your repository:
org.springframework.data.r2dbc.repository.R2dbcRepository.
2021-03-15 20:38:18.724 INFO 8692 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate
: Finished Spring Data repository scanning in 97 ms. Found 0 R2DBC repository interfaces.
2021-03-15 20:38:26.847 INFO 8692 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource
: HikariPool-1 - Starting...
2021-03-15 20:38:28.550 INFO 8692 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource
: HikariPool-1 - Start completed.
2021-03-15 20:38:42.546 INFO 8692 --- [ restartedMain] l.lockservice.StandardLockService
: Successfully acquired change log lock
2021-03-15 20:38:44.908 INFO 8692 --- [ restartedMain] l.c.StandardChangeLogHistoryService
: Reading from public.databasechangelog
2021-03-15 20:38:45.635 INFO 8692 --- [ restartedMain] l.lockservice.StandardLockService :
Successfully released change log lock
2021-03-15 20:38:45.651 INFO 8692 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource :
HikariPool-1 - Shutdown initiated...
2021-03-15 20:38:45.698 INFO 8692 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource
: HikariPool-1 - Shutdown completed.
2021-03-15 20:38:46.773 INFO 8692 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer
: LiveReload server is running on port 35729
2021-03-15 20:38:47.884 INFO 8692 --- [ restartedMain] o.s.b.web.embedded.netty.NettyWebServer :
Netty started on port 8085
2021-03-15 20:38:47.915 INFO 8692 --- [ restartedMain] c.W.W.WebFluxTestCodesApplication
: Started WebFluxTestCodesApplication in 39.523 seconds (JVM running for 45.043)
However, when I send a request using the browser, no request comes to the controllers and the following error occurs in the browser.
This application has no configured error view, so you are seeing this as a fallback.
Mon Mar 15 20:38:51 AZT 2021
[005bd2a6-1] There was an unexpected error (type=Not Found, status=404).
org.springframework.web.server.ResponseStatusException: 404 NOT_FOUND
at
org.springframework.web.reactive.resource.ResourceWebHandler
.lambda$handle$1(ResourceWebHandler.java:378)
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
|_ checkpoint ⇢ HTTP GET "/all" [ExceptionHandlingWebHandler]
Stack trace:
at
org.springframework.web.reactive.resource
.ResourceWebHandler.lambda$handle$1(ResourceWebHandler.java:378)
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:44)
at reactor.core.publisher.Mono.subscribe(Mono.java:4046)
at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber
.onComplete(FluxSwitchIfEmpty.java:81)
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onComplete(MonoFlatMap.java:181)
at reactor.core.publisher.MonoNext$NextSubscriber.onComplete(MonoNext.java:102)
at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:366)
at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:218)
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164)
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86)
at reactor.core.publisher.Mono.subscribe(Mono.java:4046)
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:173)
at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157)
at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber
.onNext(FluxSwitchIfEmpty.java:73)
at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82)
at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:281)
at reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:860)
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:127)
at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2397)
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:169)
at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2193)
at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2067)
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber
.onSubscribe(FluxMapFuseable.java:96)
at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
at reactor.core.publisher.Mono.subscribe(Mono.java:4046)
at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:448)
at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:218)
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164)
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86)
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
at reactor.core.publisher.Mono.subscribe(Mono.java:4046)
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:173)
at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
at reactor.netty.http.server.HttpServer$HttpServerHandle.onStateChange(HttpServer.java:860)
at reactor.netty.ReactorNetty$CompositeConnectionObserver.onStateChange(ReactorNetty.java:638)
at reactor.netty.transport.ServerTransport$ChildObserver.onStateChange(ServerTransport.java:478)
at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:525)
at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:94)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:209)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:832)
Request Controller Project Not Working What is the problem ? it is very important to me Please Help me
My project github link --https://github.com/Z-Farrukzada/Webflux-Reactive-Programming-example

Related

ShedLock with Spring boot with couchbase

Given my Spring boot application code:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import com.couchbase.client.java.Bucket;
import net.javacrumbs.shedlock.provider.couchbase.javaclient3.CouchbaseLockProvider;
import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;
#SpringBootApplication
#EnableScheduling
#EnableSchedulerLock(defaultLockAtMostFor = "10m")
public class MythoughtsApplication {
public static void main(String[] args) {
SpringApplication.run(MythoughtsApplication.class, args);
}
#Bean
public CouchbaseLockProvider lockProvider(Bucket bucket) {
return new CouchbaseLockProvider(bucket);
}
}
pom.xml
using the latest shedlock in the below pom.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.guru</groupId>
<artifactId>mythoughts</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mythoughts</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-couchbase</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>java-client</artifactId>
</dependency>
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>core-io</artifactId>
<version>2.3.1</version>
</dependency>
**<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-spring</artifactId>
**<version>4.37.0</version>**
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-provider-couchbase-javaclient3</artifactId>
**<version>4.37.0</version>**
</dependency>**
<dependency>
<groupId>com.unboundid</groupId>
<artifactId>unboundid-ldapsdk</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
couchbase Connection file
#Configuration
public class CouchbaseConfig extends AbstractCouchbaseConfiguration {
#Override
public String getConnectionString() {
// TODO Auto-generated method stub
return "127.0.0.1";
}
#Override
public String getUserName() {
// TODO Auto-generated method stub
return "admin";
}
#Override
public String getPassword() {
// TODO Auto-generated method stub
return "1234";
}
#Override
public String getBucketName() {
// TODO Auto-generated method stub
return "admin";
}
}
controller file
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.guru.mythoughts.service.UserService;
import net.javacrumbs.shedlock.core.LockAssert;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
#RestController
public class UserController {
#Scheduled(cron = "*/5 * * * * *")
#SchedulerLock(name = "scheduledTaskName", lockAtMostFor = "PT5M", lockAtLeastFor = "PT4M")
public void scheduledTask() {
LockAssert.assertLocked();
System.out.println("cloked");
}
}
Output with error:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.0)
2022-06-21 17:36:01.346 INFO 21152 --- [ main] c.zzz.mythoughts.MyApplication : Starting MythoughtsApplication using Java 1.8.0_271 on DESKTOP-O8IM34ASBST with PID 21152 (C:\Users\G\Downloads\mythoughts\target\classes started by in C:\Users\G\Downloads\mythoughts)
2022-06-21 17:36:01.350 INFO 21152 --- [ main] c.zzz.mythoughts.MythoughtsApplication : No active profile set, falling back to 1 default profile: "default"
2022-06-21 17:36:01.889 INFO 21152 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Couchbase repositories in DEFAULT mode.
2022-06-21 17:36:02.033 INFO 21152 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 139 ms. Found 0 Couchbase repository interfaces.
2022-06-21 17:36:02.039 INFO 21152 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Couchbase repositories in DEFAULT mode.
2022-06-21 17:36:02.061 INFO 21152 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 22 ms. Found 1 Couchbase repository interfaces.
2022-06-21 17:36:02.504 INFO 21152 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-06-21 17:36:02.514 INFO 21152 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-06-21 17:36:02.514 INFO 21152 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.63]
2022-06-21 17:36:02.751 INFO 21152 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-06-21 17:36:02.751 INFO 21152 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1346 ms
2022-06-21 17:36:03.445 INFO 21152 --- [ cb-events] com.couchbase.core : [com.couchbase.core][CoreCreatedEvent] {"clientVersion":"3.3.0","clientGitHash":"${buildNumber}","coreVersion":"2.3.1","coreGitHash":"${buildNumber}","userAgent":"couchbase-java/3.3.0 (Windows 10 10.0 amd64; Java HotSpot(TM) 64-Bit Server VM 1.8.0_271-b09)","maxNumRequestsInRetry":32768,"ioEnvironment":{"nativeIoEnabled":true,"eventLoopThreadCount":4,"eventLoopGroups":["NioEventLoopGroup"]},"ioConfig":{"captureTraffic":[],"mutationTokensEnabled":true,"networkResolution":"auto","dnsSrvEnabled":true,"tcpKeepAlivesEnabled":true,"tcpKeepAliveTimeMs":60000,"configPollIntervalMs":2500,"kvCircuitBreakerConfig":"disabled","queryCircuitBreakerConfig":"disabled","viewCircuitBreakerConfig":"disabled","searchCircuitBreakerConfig":"disabled","analyticsCircuitBreakerConfig":"disabled","managerCircuitBreakerConfig":"disabled","eventingCircuitBreakerConfig":"disabled","backupCircuitBreakerConfig":"disabled","numKvConnections":1,"maxHttpConnections":12,"idleHttpConnectionTimeoutMs":4500,"configIdleRedialTimeoutMs":300000,"memcachedHashingStrategy":"StandardMemcachedHashingStrategy"},"compressionConfig":{"enabled":true,"minRatio":0.83,"minSize":32},"securityConfig":{"tlsEnabled":false,"nativeTlsEnabled":true,"hostnameVerificationEnabled":true,"trustCertificates":null,"trustManagerFactory":null,"ciphers":[]},"timeoutConfig":{"kvMs":2500,"kvDurableMs":10000,"managementMs":75000,"queryMs":75000,"viewMs":75000,"searchMs":75000,"analyticsMs":75000,"connectMs":10000,"disconnectMs":10000,"eventingMs":75000,"backupMs":75000},"loggerConfig":{"customLogger":null,"fallbackToConsole":false,"consoleLogLevel":{"name":"INFO","resourceBundleName":"sun.util.logging.resources.logging","localizedName":"INFO"},"consoleLoggerFormatter":"DefaultLoggerFormatter","disableSlf4j":false,"loggerName":"CouchbaseLogger","diagnosticContextEnabled":false},"orphanReporterConfig":{"emitIntervalMs":10000,"sampleSize":10,"queueLength":1024,"enabled":true},"thresholdLoggingTracerConfig":{"enabled":true,"emitIntervalMs":10000,"sampleSize":10,"queueLength":1024,"kvThresholdMs":500,"queryThresholdMs":1000,"searchThresholdMs":1000,"analyticsThresholdMs":1000,"viewThresholdMs":1000},"loggingMeterConfig":{"enabled":true,"emitIntervalMs":600000},"retryStrategy":"BestEffortRetryStrategy","requestTracer":"ThresholdLoggingTracer","meter":"LoggingMeter","numRequestCallbacks":0,"scheduler":"ParallelScheduler","schedulerThreadCount":8,"transactionsConfig":{"durabilityLevel":"MAJORITY","timeoutMs":15000,"cleanupConfig":{"runLostAttemptsCleanupThread":true,"runRegularAttemptsCleanupThread":true,"cleanupWindowMs":60000,"cleanupSet":""},"numAtrs":1024,"metadataCollection":"none","scanConsistency":"none"}} {"coreId":"0xa407cf8700000001","seedNodes":[{"address":"127.0.0.1"}]}
2022-06-21 17:36:03.445 INFO 21152 --- [ cb-events] com.couchbase.transactions : [com.couchbase.transactions][TransactionsStartedEvent] Transactions successfully initialised, regular cleanup enabled=true, lost cleanup enabled=true
2022-06-21 17:36:03.452 INFO 21152 --- [ cb-events] com.couchbase.node : [com.couchbase.node][NodeConnectedEvent] Node connected {"coreId":"0xa407cf8700000001","managerPort":"8091","remote":"127.0.0.1"}
2022-06-21 17:36:03.985 WARN 21152 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'lockProvider' defined in com.guru.mythoughts.MythoughtsApplication: Unsatisfied dependency expressed through method 'lockProvider' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.couchbase.client.java.Bucket' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2022-06-21 17:36:04.026 INFO 21152 --- [ cb-events] com.couchbase.transactions.cleanup : [com.couchbase.transactions.cleanup][LogEvent] Waiting for 1 regular background threads to exit
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] c.c.transactions.cleanup.regular : [com.couchbase.transactions.cleanup.regular][LogEvent] Stopping background cleanup thread for transactions from this client
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] com.couchbase.transactions.cleanup.lost : [com.couchbase.transactions.cleanup.lost][LogEvent] Client d9110 has been told to cancel
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] com.couchbase.transactions.cleanup.lost : [com.couchbase.transactions.cleanup.lost][LogEvent] Client d9110 stopping lost cleanup process, 0 threads running
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] com.couchbase.transactions.cleanup.lost : [com.couchbase.transactions.cleanup.lost][LogEvent] Client d9110 stopped lost cleanup process and removed client from client records
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] com.couchbase.transactions.cleanup : [com.couchbase.transactions.cleanup][LogEvent] Background threads have exitted
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] com.couchbase.node : [com.couchbase.node][NodeDisconnectedEvent][667us] Node disconnected {"coreId":"0xa407cf8700000001","managerPort":"8091","remote":"127.0.0.1"}
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] com.couchbase.core : [com.couchbase.core][ShutdownCompletedEvent][19ms] Completed shutdown and closed all open buckets {"coreId":"0xa407cf8700000001"}
2022-06-21 17:36:04.118 INFO 21152 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-06-21 17:36:04.130 INFO 21152 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-06-21 17:36:04.157 ERROR 21152 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method lockProvider in com.guru.mythoughts.MythoughtsApplication required a bean of type 'com.couchbase.client.java.Bucket' that could not be found.
Action:
Consider defining a bean of type 'com.couchbase.client.java.Bucket' in your configuration.
I have given sample code and when I tried to run the application I am getting the above error. I have scheduled a method in controller and it should run for every 5 seconds.
I have followed the above in the given below link
https://gitcode.net/mirrors/lukas-krecan/ShedLock/-/tree/master/providers/couchbase
How can i solve this error?
Autowired the Cluster class and used the cluster to get the bucket details with bean creation in main class which return the bucket object. please see the same code and it is working fine.
#Autowired
Cluster cluster;
#Bean
public Bucket getBucket() {
return cluster.bucket("bucket");
}
}
Another option is to have a Cluster argument to your getBucket() bean method.
#Bean
public Bucket getBucket(Cluster cluster){
return cluster.bucket("myBucket");
}

Spring boot does not automatically create database tables on Mysql

First I already went over some solution on stacks but they did not work. I make a very basic/learning app on spring / mysql, no tables joining for the moment. The problem is tables are not creating on mysql, while everything is working. I copy my code hereunder.
Thanks in advance for the help
Console:
2021-06-15 11:25:07.895 INFO 8464 --- [ main]
c.j.v.VotingsystemApplication : Starting
VotingsystemApplication using Java 15.0.2 on LAPTOP-BQ48GM36 with PID
8464 (C:\Users\The Kash\Downloads\votingsystem\target\classes started
by The Kash in C:\Users\The Kash\Downloads\votingsystem)
2021-06-15 11:25:07.898 INFO 8464 --- [ main]
c.j.v.VotingsystemApplication : No active profile set,
falling back to default profiles: default
2021-06-15 11:25:08.734 INFO 8464 --- [ main]
.s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules
found, entering strict repository configuration mode!
2021-06-15 11:25:08.736 INFO 8464 --- [ main]
.s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data
JDBC repositories in DEFAULT mode.
2021-06-15 11:25:08.749 INFO 8464 --- [ main] .s.d.
r.c.RepositoryConfigurationDelegate : Finished Spring Data repository
scanning in 6 ms. Found 0 JDBC repository interfaces.
2021-06-15 11:25:08.760 INFO 8464 --- [ main]
.s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules
found, entering strict repository configuration mode!
2021-06-15 11:25:08.762 INFO 8464 --- [ main] .s.d.
r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA
repositories in DEFAULT mode.
2021-06-15 11:25:08.769 INFO 8464 --- [ main]
.s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data
repository scanning in 1 ms. Found 0 JPA repository interfaces.
2021-06-15 11:25:09.628 INFO 8464 --- [ main]
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with
port(s): 8080 (http)
2021-06-15 11:25:09.640 INFO 8464 --- [ main]
o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-06-15 11:25:09.640 INFO 8464 --- [ main]
org.apache.catalina.core.StandardEngine : Starting Servlet engine:
[Apache Tomcat/9.0.46]
2021-06-15 11:25:09.776 INFO 8464 --- [ main] o.a.c.c.C.
[Tomcat].[localhost].[/] : Initializing Spring embedded
WebApplicationContext
2021-06-15 11:25:09.776 INFO 8464 --- [ main]
w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext:
initialization completed in 1808 ms
2021-06-15 11:25:09.924 INFO 8464 --- [ main]
com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-06-15 11:25:10.415 INFO 8464 --- [ main]
com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start
completed.
2021-06-15 11:25:10.582 INFO 8464 --- [ main]
o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing
PersistenceUnitInfo [name: default]
2021-06-15 11:25:10.672 INFO 8464 --- [ main]
org.hibernate.Version : HHH000412: Hibernate ORM
core version 5.4.32.Final
2021-06-15 11:25:10.879 INFO 8464 --- [ main]
o.hibernate.annotations.common.Version : HCANN000001: Hibernate
Commons Annotations {5.1.2.Final}
2021-06-15 11:25:11.018 INFO 8464 --- [ main]
org.hibernate.dialect.Dialect : HHH000400: Using dialect:
org.hibernate.dialect.MySQL5Dialect
2021-06-15 11:25:11.260 INFO 8464 --- [ main]
o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform
implementation:
[org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-06-15 11:25:11.272 INFO 8464 --- [ main]
j.LocalContainerEntityManagerFactoryBean : Initialized JPA
EntityManagerFactory for persistence unit 'default'
2021-06-15 11:25:11.322 WARN 8464 --- [ main]
JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is
enabled by default. Therefore, database queries may be performed during
view rendering. Explicitly configure spring.jpa.open-in-view to disable
this warning
2021-06-15 11:25:11.735 WARN 8464 --- [ main]
ion$DefaultTemplateResolverConfiguration : Cannot find template
location: classpath:/templates/ (please add some templates or check
your Thymeleaf configuration)
2021-06-15 11:25:11.999 INFO 8464 --- [ main] o.s.b.
w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080
(http) with context path ''
2021-06-15 11:25:12.013 INFO 8464 --- [ main]
c.j.v.VotingsystemApplication : Started
VotingsystemApplication
in 4.595 seconds (JVM running for 5.166)
VotingsystemApplication.java (main app)
package com.javaenterprise.votingsystem;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class VotingsystemApplication {
public static void main(String[] args) {
SpringApplication.run(VotingsystemApplication.class, args);
}
}
application.properties
spring.datasource.url=jdbc:mysql://localhost/VotingSystem
spring.datasource.username=root
spring.datasource.password=rooting1
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.dialect =
org.hibernate.dialect.MySQL5Dialect
Citizen.java
package com.javaenterprise.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name = "citizens")
public class Citizen {
#Id
#Column(name="id")
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
#Column(name = "citizen_name")
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Citizen(Long id, String name) {
super();
this.id = id;
this.name = name;
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-
4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.javaenterprise</groupId>
<artifactId>votingsystem</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>votingsystem</name>
<description>Voting system in sprin</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
The main entry point of your application is in the com.javaenterprise.votingsystem package. This means that component and entity scanning will find classes in com.javaenterprise.votingsystem and any of its sub-packages. Your entities are in the com.javaenterprise.entity which isn't covered by this scanning.
You could solve the problem by renaming your com.javaenterprise.entity package to com.javaenterprise.votingsystem.entity. Alternatively, you can use #EntityScan to specify the packages that you want to be scanned for entities.
Use the following property:
spring.datasource.url=jdbc:mysql://localhost:3306/dbname?useSSL=false
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.use_sql_comments=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.ddl-auto=update
And Second, Please add a default constructor as well.
So ur entity class will become:
package com.javaenterprise.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name = "citizens")
#Data
#AllArgsConstructor
#NoArgsConstructor
public class Citizen {
#Id
#Column(name="id")
private Long id;
#Column(name = "citizen_name")
private String name;
}
Can you try implementing Serializable and add DEFAULT Constructor ?
You can use this in your application.properties file
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root/your username
spring.datasource.password= yourpassword
spring.datasource.url=jdbc:mysql://localhost:3306/kibria
#for mysql dialect
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto = update
spring.jpa.show-sql = true

SpringCloud-Finchley.SR2 Eureka register-center page status 404

I imported a springcloud demo , version Finchley.SR2, after starting the application,I couldn't visit Eureka register center page,status 404.
I don't have and controller yet,Only a #SpringBootApplication
Same problem on eclipse and Idea
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Apr 17 10:46:08 CST 2019
There was an unexpected error (type=Not Found, status=404).
No message available
If I use version Finchley.SR1 with dependency jersey-bundle 1.19, everything is normal.
Here is the pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>groupId</groupId>
<artifactId>register-center</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>register-center</name>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR2</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.19</version>
</dependency>
-->
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
here is the starting log that console output:
2019-04-17 10:45:55.070 INFO 6608 --- [ main] c.g.c.h.HubRegisterCenterApplication : No active profile set, falling back to default profiles: default
2019-04-17 10:45:55.930 WARN 6608 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2019-04-17 10:45:56.189 INFO 6608 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=b735a91d-6156-3751-9e56-6f2bcdd0ff57
2019-04-17 10:45:56.294 INFO 6608 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$e5276a08] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-04-17 10:45:56.982 INFO 6608 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8761 (http)
2019-04-17 10:45:57.007 INFO 6608 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-04-17 10:45:57.007 INFO 6608 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.17]
2019-04-17 10:45:57.277 INFO 6608 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-04-17 10:45:57.277 INFO 6608 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2190 ms
2019-04-17 10:45:57.390 WARN 6608 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-04-17 10:45:57.390 INFO 6608 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-04-17 10:45:57.408 INFO 6608 --- [ main] c.netflix.config.DynamicPropertyFactory : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration#4af70944
2019-04-17 10:45:58.631 WARN 6608 --- [ main] o.s.c.n.a.ArchaiusAutoConfiguration : No spring.application.name found, defaulting to 'application'
2019-04-17 10:45:58.632 WARN 6608 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-04-17 10:45:58.632 INFO 6608 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-04-17 10:45:58.854 INFO 6608 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-04-17 10:45:59.276 WARN 6608 --- [ main] o.s.b.a.f.FreeMarkerAutoConfiguration : Cannot find template location(s): [classpath:/templates/] (please add some templates, check your FreeMarker configuration, or set spring.freemarker.checkTemplateLocation=false)
2019-04-17 10:45:59.470 INFO 6608 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-04-17 10:45:59.716 INFO 6608 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2019-04-17 10:45:59.756 INFO 6608 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2019-04-17 10:45:59.758 INFO 6608 --- [ main] com.netflix.discovery.DiscoveryClient : Client configured to neither register nor query for data.
2019-04-17 10:45:59.775 INFO 6608 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1555469159773 with initial instances count: 0
2019-04-17 10:45:59.781 INFO 6608 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application UNKNOWN with eureka with status UP
2019-04-17 10:45:59.840 INFO 6608 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8761 (http) with context path ''
2019-04-17 10:45:59.844 INFO 6608 --- [ main] c.g.c.h.HubRegisterCenterApplication : Started HubRegisterCenterApplication in 6.441 seconds (JVM running for 7.261)
2019-04-17 10:46:08.612 INFO 6608 --- [nio-8761-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-04-17 10:46:08.612 INFO 6608 --- [nio-8761-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2019-04-17 10:46:08.618 INFO 6608 --- [nio-8761-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 6 ms
Here is my application.yml:
server:
port: 8761
eureka:
client:
register-with-eureka: false
fetch-registry: false
Here is my Application class:
#SpringBootApplication
#EnableEurekaServer
public class HubRegisterCenterApplication {
public static void main(String[] args) {
SpringApplication.run(HubRegisterCenterApplication.class, args);
}
}
Problem solved.
use mvn install command,and I found that there is some problems in maven dependency jar file. delete them and re-download,problem solved
Use application.properties file instead of application.yml file.
like
spring.application.name=cart-service
server.port=8082
It worked for me.

Spring Cloud Vault - Missing required header: X-Config-Token

I was following the getting started guides for spring config server and vault when I run into a issue related to vault I am unable to resolve. The config server is however working fine with GIT but not with Vault. Below is the code and config I am using -
Here is the configserver code -
#EnableConfigServer
#SpringBootApplication
public class SpringConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(SpringConfigServerApplication.class, args);
}
}
And the corresponding application.yml -
spring:
application:
name: configserver
cloud:
config:
server:
vault:
port: 8200
host: 127.0.0.1
git:
uri: https://github.com/weekly-drafts/config-repo-spring-cloud-configserver-vault
profiles:
active: default, native, git, vault
server:
port: 8888
configserver pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rockingengineering</groupId>
<artifactId>spring-config-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>spring-config-server</name>
<description>Spring Config Server Application</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Here is my configclient code
#SpringBootApplication
public class VaultApplication {
public static void main(String[] args) {
SpringApplication.run(VaultApplication.class, args);
}
}
and property loading controller. This code is loading properties from GIT but not vault.
#RefreshScope
#RestController
public class VaultController {
#Value("${client.pseudo.property}")
private String pseudoProperty;
#Value("${client.pseudo.property.vault}")
private String proeprtyFromVault;
#GetMapping("/property")
public ResponseEntity<String> getProperty() {
return ResponseEntity.ok(pseudoProperty);
}
#GetMapping("/property/vault")
public ResponseEntity<String> getPropertyFromVault() {
return ResponseEntity.ok(proeprtyFromVault);
}
}
Configclient bootstrap.yml -
spring:
application:
name: configclient
cloud:
vault:
token: f474964a-89bf-39e6-2e37-3d7de918f762
uri: http://localhost:8888
config:
token: f474964a-89bf-39e6-2e37-3d7de918f762
uri: http://localhost:8888
headers:
X-Vault-Token: f474964a-89bf-39e6-2e37-3d7de918f762
server:
port: 8080
ConfigClient pom.xml -
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rockingengineering</groupId>
<artifactId>spring-cloud-vault</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>spring-cloud-vault</name>
<description>Spring Cloud Vault Application</description>
<inceptionYear>2018</inceptionYear>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath />
</parent>
<properties>
<spring-cloud-vault-dependencies.version>1.0.2.RELEASE</spring-cloud-vault-dependencies.version>
<log4j.version>1.2.17</log4j.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-vault-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>spring-cloud-vault</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Response from Vault -
vault kv get -format=json secret/configclient
{
"request_id": "1a8dba22-d120-f7b9-13a2-8f2107786c29",
"lease_id": "",
"lease_duration": 0,
"renewable": false,
"data": {
"data": {
"client.pseudo.property.vault": "Property value loaded from Vault"
},
"metadata": {
"created_time": "2018-10-11T12:36:24.165749Z",
"deletion_time": "",
"destroyed": false,
"version": 2
}
},
"warnings": null
}
I am able to use vault from CLI using the same token. The error I am getting is -
2018-10-11 18:07:49.946 INFO 97999 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#3fc2959f: startup date [Thu Oct 11 18:07:49 IST 2018]; root of context hierarchy
2018-10-11 18:07:50.389 INFO 97999 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$c21aa722] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-10-11 18:07:50.913 INFO 97999 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.5.RELEASE)
2018-10-11 18:07:53.579 WARN 97999 --- [ main] o.s.v.a.LifecycleAwareSessionManager : Cannot enhance VaultToken to a LoginToken: Token self-lookup failed: 500 {"timestamp":"2018-10-11T12:37:53.557+0000","status":500,"error":"Internal Server Error","message":"No such label: token","path":"/v1/auth/token/lookup-self"}
2018-10-11 18:07:53.603 WARN 97999 --- [ main] LeaseEventPublisher$LoggingErrorListener : [RequestedSecret [path='secret/configclient', mode=ROTATE]] Lease [leaseId='null', leaseDuration=PT0S, renewable=false] Status 400 secret/configclient: {"timestamp":"2018-10-11T12:37:53.594+0000","status":400,"error":"Bad Request","message":"Missing required header: X-Config-Token","path":"/v1/secret/configclient"}
2018-10-11 18:07:53.632 WARN 97999 --- [ main] LeaseEventPublisher$LoggingErrorListener : [RequestedSecret [path='secret/application', mode=ROTATE]] Lease [leaseId='null', leaseDuration=PT0S, renewable=false] Status 400 secret/application: {"timestamp":"2018-10-11T12:37:53.630+0000","status":400,"error":"Bad Request","message":"Missing required header: X-Config-Token","path":"/v1/secret/application"}
org.springframework.vault.VaultException: Status 400 secret/application: {"timestamp":"2018-10-11T12:37:53.630+0000","status":400,"error":"Bad Request","message":"Missing required header: X-Config-Token","path":"/v1/secret/application"}
at org.springframework.vault.client.VaultResponses.buildException(VaultResponses.java:89) ~[spring-vault-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.vault.client.VaultResponses.buildException(VaultResponses.java:81) ~[spring-vault-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.vault.core.VaultTemplate.lambda$doRead$1(VaultTemplate.java:328) ~[spring-vault-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.vault.core.VaultTemplate.doWithSession(VaultTemplate.java:307) ~[spring-vault-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.vault.core.VaultTemplate.doRead(VaultTemplate.java:317) ~[spring-vault-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.vault.core.VaultTemplate.read(VaultTemplate.java:212) ~[spring-vault-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.vault.core.lease.SecretLeaseContainer.doGetSecrets(SecretLeaseContainer.java:545) [spring-vault-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.vault.core.lease.SecretLeaseContainer.start(SecretLeaseContainer.java:357) [spring-vault-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.vault.core.lease.SecretLeaseContainer.addRequestedSecret(SecretLeaseContainer.java:316) [spring-vault-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.vault.core.env.LeaseAwareVaultPropertySource.loadProperties(LeaseAwareVaultPropertySource.java:147) [spring-vault-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.vault.core.env.LeaseAwareVaultPropertySource.<init>(LeaseAwareVaultPropertySource.java:133) [spring-vault-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.cloud.vault.config.LeasingVaultPropertySourceLocator.createVaultPropertySource(LeasingVaultPropertySourceLocator.java:151) [spring-cloud-vault-config-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.cloud.vault.config.LeasingVaultPropertySourceLocator.createVaultPropertySource(LeasingVaultPropertySourceLocator.java:88) [spring-cloud-vault-config-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.cloud.vault.config.VaultPropertySourceLocatorSupport.doCreatePropertySources(VaultPropertySourceLocatorSupport.java:170) [spring-cloud-vault-config-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.cloud.vault.config.VaultPropertySourceLocatorSupport.createCompositePropertySource(VaultPropertySourceLocatorSupport.java:145) [spring-cloud-vault-config-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.cloud.vault.config.VaultPropertySourceLocatorSupport.locate(VaultPropertySourceLocatorSupport.java:116) [spring-cloud-vault-config-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:94) [spring-cloud-context-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:654) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:390) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:331) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at com.rockingengineering.vault.VaultApplication.main(VaultApplication.java:10) [classes/:na]
2018-10-11 18:07:53.633 INFO 97999 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='vault', propertySources=[LeaseAwareVaultPropertySource {name='secret/configclient'}, LeaseAwareVaultPropertySource {name='secret/application'}]}
2018-10-11 18:07:53.639 INFO 97999 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2018-10-11 18:07:56.496 INFO 97999 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=configclient, profiles=[default], label=null, version=null, state=null
2018-10-11 18:07:56.496 INFO 97999 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='https://github.com/weekly-drafts/config-repo-spring-cloud-configserver-vault/configclient.yml'}]}
2018-10-11 18:07:56.502 INFO 97999 --- [ main] c.r.vault.VaultApplication : No active profile set, falling back to default profiles: default
2018-10-11 18:07:56.516 INFO 97999 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#60a2630a: startup date [Thu Oct 11 18:07:56 IST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#3fc2959f
2018-10-11 18:07:57.909 INFO 97999 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=e9255d82-de63-3800-b389-53a2229e780a
2018-10-11 18:07:58.032 INFO 97999 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$c21aa722] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-10-11 18:07:58.564 INFO 97999 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-10-11 18:07:58.589 INFO 97999 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-10-11 18:07:58.589 INFO 97999 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.34
2018-10-11 18:07:58.593 INFO 97999 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/naveen/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2018-10-11 18:07:58.706 INFO 97999 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-10-11 18:07:58.706 INFO 97999 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2190 ms
2018-10-11 18:07:59.377 INFO 97999 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-10-11 18:07:59.965 INFO 97999 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/property],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> com.rockingengineering.vault.controller.VaultController.getProperty()
2018-10-11 18:07:59.966 INFO 97999 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/property/vault],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> com.rockingengineering.vault.controller.VaultController.getPropertyFromVault()
2018-10-11 18:07:59.969 INFO 97999 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v2/api-docs],methods=[GET],produces=[application/json || application/hal+json]}" onto public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)
2018-10-11 18:08:00.101 INFO 97999 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2018-10-11 18:08:00.116 INFO 97999 --- [ main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-10-11 18:08:00.117 INFO 97999 --- [ main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-10-11 18:08:00.118 INFO 97999 --- [ main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto protected java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-10-11 18:08:00.266 INFO 97999 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-10-11 18:08:00.397 INFO 97999 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#60a2630a: startup date [Thu Oct 11 18:07:56 IST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#3fc2959f
2018-10-11 18:08:00.443 INFO 97999 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-10-11 18:08:00.443 INFO 97999 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-10-11 18:08:00.798 INFO 97999 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-10-11 18:08:00.811 INFO 97999 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'environmentManager' has been autodetected for JMX exposure
2018-10-11 18:08:00.812 INFO 97999 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'refreshScope' has been autodetected for JMX exposure
2018-10-11 18:08:00.815 INFO 97999 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2018-10-11 18:08:00.821 INFO 97999 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2018-10-11 18:08:00.831 INFO 97999 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2018-10-11 18:08:00.842 INFO 97999 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=60a2630a,type=ConfigurationPropertiesRebinder]
2018-10-11 18:08:00.985 INFO 97999 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483647
2018-10-11 18:08:00.986 INFO 97999 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2018-10-11 18:08:01.004 INFO 97999 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2018-10-11 18:08:01.016 INFO 97999 --- [ main] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
2018-10-11 18:08:01.099 WARN 97999 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.vaultController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'client.pseudo.property.vault' in value "${client.pseudo.property.vault}"
2018-10-11 18:08:01.101 INFO 97999 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2018-10-11 18:08:01.102 INFO 97999 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans
2018-10-11 18:08:01.107 INFO 97999 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-10-11 18:08:01.131 INFO 97999 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-10-11 18:08:01.138 ERROR 97999 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.vaultController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'client.pseudo.property.vault' in value "${client.pseudo.property.vault}"
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:378) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:353) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.getBean(GenericScope.java:390) ~[spring-cloud-context-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at com.rockingengineering.vault.VaultApplication.main(VaultApplication.java:10) [classes/:na]
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'client.pseudo.property.vault' in value "${client.pseudo.property.vault}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:172) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:237) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:211) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]
... 33 common frames omitted
2018-10-11 18:08:01.139 INFO 97999 --- [ Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#3fc2959f: startup date [Thu Oct 11 18:07:49 IST 2018]; root of context hierarchy
2018-10-11 18:08:01.141 INFO 97999 --- [ Thread-2] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService
Can anyone tell what I am missing here?
You don't need to use spring-cloud-starter-vault-config for your config-client in this particular case. Basically your client doesn't know anything about Vault. You just need to pass token (spring.cloud.config.token) and config-server will take care of getting properties from Vault using this token. spring-cloud-starter-vault-config is used in case when you want to get data directly from Vault (not through config-server). Your configuration (bootstrap.yml) should look like this:
spring:
application:
name: configclient
cloud:
config:
token: your_vault_token
uri: http://localhost:8888
In config-server you need to support composite configuration from git and Vault. So you need to put 2 profiles: git and vault.
The tricky moment is that Vault has now 2 versions for KV Secrets Engine (https://www.vaultproject.io/api/secret/kv/index.html) so make sure that you use same version in vault and config-server. Because based on documentation kv version 2 is enabled by default in dev mode:
Additionally, when running a dev-mode server, the v2 kv secrets engine is enabled by default at the path secret/ (for non-dev servers, it is currently v1). It can be disabled, moved, or enabled multiple times at different paths. Each instance of the KV secrets engine is isolated and unique.
See: https://www.vaultproject.io/docs/secrets/kv/kv-v2.html
Spring Cloud Config has support of both versions of Vault KV storage:
Vault 0.10.0 introduced a versioned key-value backend (k/v backend version 2) that exposes a different API than earlier versions, it now requires a data/ between the mount path and the actual context path and wraps secrets in a data object. Setting kvVersion=2 will take this into account.
More: http://cloud.spring.io/spring-cloud-static/spring-cloud-config/2.0.1.RELEASE/single/spring-cloud-config.html#vault-backend
So based on all of this information, you configserver application.yml should look like this:
server:
port: 8888
spring:
application:
name: configserver
profiles:
active: git, vault
cloud:
config:
server:
vault:
port: 8200
host: 127.0.0.1
kvVersion: 2 #may be 1 depends on Vault configuration
git:
uri: https://github.com/weekly-drafts/config-repo-spring-cloud-configserver-vault
The right configuration is spring.cloud.config.token, you have the right config in the wrong file. Try adding it in application.yml instead, basically everything that comes before the Spring Boot Logo is configured through bootstrap.yml after the logo, Spring unloads bootstrap.yml and loads application.yml and then it tries to get the configuration from Spring Config Server.
What I usually do is to add is as an environment variable (SPRING_CLOUD_CONFIG_TOKEN), so no matter when it tries to reach the config, the value will be there.

spring boot application failed to autowired feign client

I created a sample project of Spring Boot to understand the Feign client functionality, when run it gives below error.
Field remoteCallClient in com.example.demo.RestClient required a bean of type 'com.example.demo.RemoteCallClient' that could not be found.
Action:
Consider defining a bean of type 'com.example.demo.RemoteCallClient' in your configuration.
I tried various ways but it could not be resolved, provided the entire source code of the sample project.
POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>mictro-service-3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>micro-service-3</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
<version>1.4.5.RELEASE</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Application's main class
#SpringBootApplication
#EnableFeignClients
public class MicroService3Application {
public static void main(String[] args) {
SpringApplication.run(MicroService3Application.class, args);
}
}
Feign client
#FeignClient(url="https://jsonplaceholder.typicode.com/",value="USERS")
public interface RemoteCallClient {
#RequestMapping("users")
public String getUsers();
}
Rest controller
#RestController
public class RestClient {
#Autowired
private RemoteCallClient remoteCallClient;
public String getRemoteClient() {
return remoteCallClient.getUsers();
}
}
}
Logs
2018-07-23 11:22:57.668 INFO 6556 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#4efbca5a: startup date [Mon Jul 23 11:22:57 PDT 2018]; root of context hierarchy
2018-07-23 11:22:57.852 INFO 6556 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-23 11:22:57.877 INFO 6556 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$62660f56] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.3.RELEASE)
2018-07-23 11:22:58.066 INFO 6556 --- [ main] c.example.demo.MicroService3Application : No active profile set, falling back to default profiles: default
2018-07-23 11:22:58.075 INFO 6556 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#6b58b9e9: startup date [Mon Jul 23 11:22:58 PDT 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#4efbca5a
2018-07-23 11:22:58.712 INFO 6556 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=27c00c1a-419a-35b3-9b1b-f3a4f9bbf439
2018-07-23 11:22:58.726 INFO 6556 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-23 11:22:58.800 INFO 6556 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$62660f56] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-23 11:22:58.992 INFO 6556 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-07-23 11:22:59.006 INFO 6556 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-07-23 11:22:59.006 INFO 6556 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-07-23 11:22:59.009 INFO 6556 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_92\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_92/bin/server;C:/Program Files/Java/jre1.8.0_92/bin;C:/Program Files/Java/jre1.8.0_92/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_92\bin;C:\Program Files (x86)\Skype\Phone\;C:\apache-tomcat\bin\;F:\apache-maven-3.5.0\bin;;E:\eclipse\oxygen\eclipse;;.]
2018-07-23 11:22:59.165 INFO 6556 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-07-23 11:22:59.165 INFO 6556 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1090 ms
2018-07-23 11:22:59.371 WARN 6556 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2018-07-23 11:22:59.371 INFO 6556 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2018-07-23 11:22:59.379 INFO 6556 --- [ost-startStop-1] c.netflix.config.DynamicPropertyFactory : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration#156f04f8
2018-07-23 11:23:00.180 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-07-23 11:23:00.183 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-23 11:23:00.184 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-23 11:23:00.184 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-07-23 11:23:00.184 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-07-23 11:23:00.184 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpTraceFilter' to: [/*]
2018-07-23 11:23:00.184 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webMvcMetricsFilter' to: [/*]
2018-07-23 11:23:00.209 WARN 6556 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'restClient': Unsatisfied dependency expressed through field 'remoteCallClient'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.demo.RemoteCallClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
2018-07-23 11:23:00.210 WARN 6556 --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method 'close' failed on bean with name 'eurekaRegistration': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
2018-07-23 11:23:00.212 INFO 6556 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-07-23 11:23:00.225 INFO 6556 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-07-23 11:23:00.353 ERROR 6556 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field remoteCallClient in com.example.demo.RestClient required a bean of type 'com.example.demo.RemoteCallClient' that could not be found.
Action:
Consider defining a bean of type 'com.example.demo.RemoteCallClient' in your configuration.
For those, who included the Openfeign dependency and the feign client still cannot be autowired...
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
You have to also include the #EnableFeignClients configuration annotation which scans for the #FeignClient interfaces. Otherwise these clients remain ignored.
#EnableFeignClients
#SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication .class, args);
}
}
Use below Feign Dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
Make sure RemoteCallClient is not in different package than main application class. if it is added #ComponentScan("package")
I was battling the similar issue. I see that you already have spring-cloud-starter-openfeign dependency. I recommend that you remove the older feign dependency that exists in your POM spring-cloud-starter-feign 1.4.5.RELEASE. If your feignClient resides in a different app then upgrade both apps to be on similar to be on same versions. That worked for me. Hope it works for you!
I am using
spring-boot-starter-parent 2.1.2.RELEASE
spring-cloud-dependencies Greenwich.RELEASE
and have the following in my dependencies
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

Resources