Field properties in org.springframework.cloud.netflix.turbine.stream.TurbineStreamAutoConfiguration required a bean of type - spring

I went through links like: Spring Boot + Eureka Server + Hystrix with Turbine: empty turbine.stream, but still did not worked for me. This question is continuation of Unable to connect to Command Metric Stream. in Hystrix Dashboard issue.
My source code: https://github.com/javaHelper/spring-cloud-cordinating-services/tree/master/Protecting-Systems-with-Circuit-Breakers
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-01-15 10:46:04.141 ERROR 4380 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field properties in org.springframework.cloud.netflix.turbine.stream.TurbineStreamAutoConfiguration required a bean of type 'org.springframework.cloud.netflix.turbine.stream.TurbineStreamProperties' that could not be found.
The injection point has the following annotations:
- #org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'org.springframework.cloud.netflix.turbine.stream.TurbineStreamProperties' in your configuration.
Simply trying to start the
turbine::
TurbineApplication.java
#SpringBootApplication
#EnableTurbine
public class TurbineApplication {
public static void main(String[] args) {
SpringApplication.run(TurbineApplication.class, args);
}
}
application.properties
server.port=3000
spring.application.name=turbine-aggregator
eureka.client.service-url.defaultZone=http://localhost:8761/eureka
turbine.app-config=weather-app,datetime-app
turbine.cluster-name-expression=new String("default")

remove the turbine stream dependencies from the pom.xml
That should resolve the problem.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine-stream</artifactId>
</dependency>

Maybe you need to configure Spring to enable configuration properties for turbine?
#Configuration
#EnableConfigurationProperties(TurbineStreamProperties.class)
public class TurbineConfig {
}

Related

Parameter 0 of method websocketRoutingFilter in org.springframework.cloud.gateway.config.GatewayAutoConfiguration required a bean of type

I am developing code by taking reference from : https://piotrminkowski.wordpress.com/2018/04/26/quick-guide-to-microservices-with-spring-boot-2-0-eureka-and-spring-cloud/. In this example, I'm using Spring Boot V 2.1.1.RELEASE and spring-cloud-dependencies as Finchley.RELEASE.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
I am getting below error while starting the gateway-service:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-12-21 19:59:47 ERROR [gateway-service,,,]
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method websocketRoutingFilter in org.springframework.cloud.gateway.config.GatewayAutoConfiguration required a bean of type 'org.springframework.web.reactive.socket.client.WebSocketClient' that could not be found.
The following candidates were found but could not be injected:
- Bean method 'reactorNettyWebSocketClient' in 'GatewayAutoConfiguration.NettyConfiguration' not loaded because #ConditionalOnClass did not find required class 'reactor.ipc.netty.http.client.HttpClient'
Action:
Consider revisiting the entries above or defining a bean of type 'org.springframework.web.reactive.socket.client.WebSocketClient' in your configuration.
And also getting below error while starting proxy-service. How can I resolve this?
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-12-21 20:02:19 ERROR [proxy-service,,,]
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'proxyRequestHelper', defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulProxyAutoConfiguration$NoActuatorConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulProxyAutoConfiguration$EndpointConfiguration.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
GatewayApplication.java
#SpringBootApplication
#EnableDiscoveryClient
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
}
}
bootstrap.yml
spring:
application:
name: gateway-service
cloud:
config:
uri: http://localhost:8088
ProxyApplication.java
#SpringBootApplication
#EnableZuulProxy
#EnableSwagger2
public class ProxyApplication {
public static void main(String[] args) {
SpringApplication.run(ProxyApplication.class, args);
}
}
ProxyApi.java
#Configuration
public class ProxyApi {
#Autowired
ZuulProperties properties;
#Primary
#Bean
public SwaggerResourcesProvider swaggerResourcesProvider() {
return () -> {
List<SwaggerResource> resources = new ArrayList<>();
properties.getRoutes().values().stream()
.forEach(route -> resources.add(createResource(route.getServiceId(), route.getId(), "2.0")));
return resources;
};
}
private SwaggerResource createResource(String name, String location, String version) {
SwaggerResource swaggerResource = new SwaggerResource();
swaggerResource.setName(name);
swaggerResource.setLocation("/" + location + "/v2/api-docs");
swaggerResource.setSwaggerVersion(version);
return swaggerResource;
}
}
I've seen https://github.com/spring-cloud/spring-cloud-gateway/issues/319, but I still want to use the Spring Boot V2.1.1.RELEASE.

Consider defining a bean of type 'reactor.core.scheduler.Scheduler' in your configuration

I'm using SpringBoot2, Spring5 in my Java micro service application. I have required dependencies including the Scheduler. Build is fine without any compilation error but during run time, I'm getting below error in PooledAsyncRunner:-
***************************** APPLICATION FAILED TO START
*************************** Description: Parameter 0 of constructor in com.connector.async.core.PooledAsyncRunner required a bean of type
'reactor.core.scheduler.Scheduler' that could not be found. Action:
Consider defining a bean of type 'reactor.core.scheduler.Scheduler' in
your configuration.
#Service
public class PooledAsyncRunner implements AsyncRunner {
private final Scheduler scheduler;
#Autowired
public PooledAsyncRunner(Scheduler scheduler) {
this.scheduler = scheduler;
}
}
Below is spring main application file where I have explicitly annotated auto-configuration:-
#SpringBootApplication
#EnableAutoConfiguration
public class MarketApplication {
}
I have reactor-core dependency as well in pom.xml.
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.1.8.RELEASE</version>
</dependency>
Please advise. Thanks

SpringBoot Fails now when I switch from spring data neo4j 4.1.3 to 5.0.0

Background
I have an application with spring data neo4j, and I switched from 4.1.3 to 5.0.0.
I believe that I have made all the necessary changes to convert my code over but I still get errors.
My current version of spring boot is
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>1.4.1.RELEASE</version>
</dependency>
Problem
When I run: mvn spring-boot:run in the command line,
I get an error:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field actionRepository in myproject.service.ActionServiceImpl required a bean of type 'myproject.repository.ActionRepository' that could not be found.
Action:
Consider defining a bean of type 'myproject.repository.ActionRepository' in your configuration
My myproject.Application.java is currently
#SpringBootApplication
#EnableTransactionManagement
#EnableSwagger2
#EntityScan(basePackages = "myproject.domain")
public class Application {
public static void main(String[] args) {
new SpringApplication(Application.class).run(args);
}
#Bean
public Docket Api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.pathMapping("/")
.apiInfo(apiInfo());
}
private springfox.documentation.service.ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Service API")
}
}
And this does not find any of my controllers like myproject.controller.ActionController.java which contains
...
#RestController
#Api(value = "Action", description = "Actions Management API")
#RequestMapping(value = "/api/action")
public class ActionController extends Controller<Action> {
...
Attempt #1
If I add the annotation #ComponentScan({"myproject.request"}) to my Application class, the error goes away, but spring boot cannot load any controllers and as such my Swagger shows no APIs and no controllers are run. This is not the solution. #SpringBootApplication should take care of all this.
Question
How do I reconfig spring boot to start working like it did in version 4.1.3 of spring data neo4j?
UPDATE 1 ATTEMPT #2
I tried adding this annotation to my class Application
#EnableNeo4jRepositories("myproject.repository")
And the error changed to something less clean:
...
2017-10-05 13:19:46.992 ERROR 561 --- [ main] o.s.boot.SpringApplication : Application startup failed
java.lang.NoSuchMethodError: org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/util/Optional;
at org.springframework.data.neo4j.repository.config.Neo4jRepositoryConfigurationExtension.postProcess(Neo4jRepositoryConfigurationExtension.java:110) ~[spring-data-neo4j-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:130) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
at org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport.registerBeanDefinitions(RepositoryBeanDefinitionRegistrarSupport.java:83) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
...
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.1.RELEASE:run (default-cli) on project myproject: An exception occurred while running. null: InvocationTargetException: org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/util/Optional; -> [Help 1]
[ERROR]
...
UPDATE 2
In an attempt to use the #EnableNeo4jRepositories("myproject.repository") and bypass the error in Update 1, I tried:
mvn clean install spring-boot:repackage
And it gave a Build Success, but the same error persists:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.1.RELEASE:run (default-cli) on project myproject: An exception occurred while running. null: InvocationTargetException: org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/util/Optional; -
UPDATE 3
I have the new annotation and changed my pom from:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.12.0.RELEASE</version>
</dependency>
to
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
and now mvn spring-boot:run
gives the error:
***************************
APPLICATION FAILED TO START
***************************
Description:
A component required a bean named 'getSessionFactory' that could not be found.
Action:
Consider defining a bean named 'getSessionFactory' in your configuration.
Try adding this annotation on your configuration class :
#EnableNeo4jRepositories("myproject.repository")
Update :
I just saw you're on Spring boot 1.4. SDN 5 is only compatible with Spring Boot 2.0.
Details are in the compatibility table.

not able to autowire in spring boot

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-05-06 20:50:51.844 ERROR 2264 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field petRepo in com.pet.controller.PetController required a bean of type 'com.pet.repository.PetRepository' that could not be found.
Action:
Consider defining a bean of type 'com.pet.repository.PetRepository' in your configuration.
try adding #Repository annotation to your repo class
#Repository
public interface PetRepository <T,ID extends Serializable> extends CrudRepository{
}

Spring Data Rest Boot app fails to start with Java config class

I'm trying to run simple Spring Data Rest Boot app (v1.2.3.RELEASE) with only one small modification from working Spring reference example app (http://spring.io/guides/gs/accessing-mongodb-data-rest/) and it failed to start.
To be more specific when I use:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
and just following simple code configuration:
public class Application {
public static void main(String[] args){
SpringApplication.run(Config.class, args);
}
}
#SpringBootApplication
public class Config {
}
without anything else I'm getting following error on startup:
2015-04-20 12:07:32.250 ERROR 5693 --- [ main]
o.s.boot.SpringApplication : Application startup failed
org.springframework.context.ApplicationContextException: Unable to
start embedded container; nested exception is
org.springframework.boot.context.embedded.EmbeddedServletContainerException:
Unable to start embedded Tomcat ...
Caused by:
java.lang.ClassCastException:
jug.ua.json.test.Config$$EnhancerBySpringCGLIB$$79797226 cannot be
cast to
org.springframework.data.rest.core.config.RepositoryRestConfiguration
at
org.springframework.boot.autoconfigure.data.rest.SpringBootRepositoryRestMvcConfiguration$$EnhancerBySpringCGLIB$$3a999d99.config()
...
However following code configuration is working fine:
#SpringBootApplication
public class Application {
public static void main(String[] args){
SpringApplication.run(Application.class, args);
}
}
Also if instead I use:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
separate Java config class approach is working fine as well...
What I'm doing wrong, cause I can't believe I spotted such an obvious bug?
Thank you,
Oleg
The problem appears to be due to a name clash between the config bean method on SpringBootRepositoryRestMvcConfiguration (inherited from Spring Data REST's RepositoryRestMvcConfiguration) and your configuration class named Config. Renaming it to something other than Config should get things working again.

Resources