In Spring Boot 2.1.3 not able to exclude Couchbase Auto Configuration - spring

I have a java project configured with gradle 5 with spring boot 2.1.3. I am trying to create a simple rest application to use Mongo-db repository and JPA with MySQL with a simple service.
I am not intended to use couch-base. although Couch base/reactive Auto configuration is loading and creating an issue, I am not able exclude Couch auto configuration and getting below exception -
java.io.FileNotFoundException: class path resource [org/springframework/data/couchbase/config/AbstractReactiveCouchbaseDataConfiguration.class] cannot be opened because it does not exist.
I tried to exclude all Couchbase Autoconfiguration without any success
"#SpringBootApplication(exclude = {
SpringBootCouchbaseConfigurer.class,
CouchbaseRepositoriesAutoConfiguration.class,
CouchbaseDataProperties.class,
CouchbaseReactiveRepositoriesAutoConfiguration.class,
CouchbaseReactiveDataAutoConfiguration.class,
CouchbaseDataAutoConfiguration.class,
CouchbaseAutoConfiguration.class,
CouchbaseConfiguration.class
})"
If I could add spring-data-couchbase dependency it works. but I don't want to include Couch-base unnecessarily with application.
I am looking for a help/workaround to exclude the Couch-base auto configuration.

Related

Load beans/controller from external jar in spring boot without changing config class

I want to load a bean from a external jar into spring boot project. But I don't want to make changes to existing spring boot config file. I want same behavior like actuator. Just add dependency and bean or endpoint will be available in spring boot

Prevent SpringBoot from creating an EmbeddedServletContainer

I'm trying to convert an existing spring application into a spring boot application. this application is not a web application but somewhere deep in it's maven dependencies hierarchy it includes a spring-web jar and therefore spring-boot tries to autoconfigure a WebEnvironment and in turn complains about not finding an EmbeddedServletContainerFactory. But this is intended as I'm using spring-boot-starter instead of spring-boot-starter-web.
My questing is: how can I prevent spring-boot from autodiscovering web specific items in the classpath? I already tried something like
#EnableAutoConfiguration(exclude = { EmbeddedServletContainerAutoConfiguration.class })
but it doesn't seem to work. Debugging the startup process I see that it runs into a method called deduceWebEnvironment() which is called unconditionally. This method returns true as soon as the following classes are on the classpath:
javax.servlet.Servlet, org.springframework.web.context.ConfigurableWebApplicationContext
But again, even this classes exist in the cp, I don't want to startup a web-application.
Try new SpringApplicationBuilder(YourApp.class).setWebEnvironment(false).run(args) You can also disable the web mode via configuration in application.properties
spring.main.web-environment=false
See the documentation

Possible to use Spring Boot 1.3.0.M1 with Spring Cloud?

I'd like to be able to start using Spring Boot 1.3.0.M1 (and by extension Spring 4.2.0.RC1) along with Spring Cloud (config server, eureka, ribbon, feign, and zuul).
I'm using a gradle build, so initially I was using the dependencyManagement plugin like this:
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-starter-parent:1.0.3.BUILD-SNAPSHOT"
}
}
But that means that no matter what version of spring boot I try to include, it gets overridden.
Instead I tried to manually include all the dependencies that the cloud starters include in the build and separately include spring boot 1.3.0.M1, but on server startup that leads to:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'servoMetricCollector' defined in class path resource [org/springframework/cloud/netflix/servo/ServoMetricsAutoConfiguration.class]
Any suggestions would be appreciated.
There is an open issue to support Spring Boot 1.3.0.

Spring Boot blows up when using solrj but not spring-boot-starter-data-solr

I am trying to port an existing Spring application across to Spring Boot. I am NOT using the spring-boot-starter-data-solr starter however I have apache solrj (5.0.0) on my classpath.
During startup the app blows up. It seems that spring boot sees the solr classes and assumes that I also have spring-boot-starter-data-solr on the classpath. In particular I get this error:
java.lang.IllegalArgumentException: #ConditionalOnMissingBean
annotations must specify at least one bean (type, name or annotation)
If I drop the solrj dependency and use spring-boot-starter-data-solr instead it is ok. However I don't need the spring-data-solr integration and doing so will force me to backport our app to the 4.7.x release of solr.
Is anyone aware of a workaround for this?
So it seems the problem was caused by spring boot's dependency on solrj 4.7.x whereas I am using 5.0.0
I fixed it by using
#SpringBootApplication(exclude = {SolrAutoConfiguration.class})
To tell boot to ignore the SolrAutoConfiguration completely.

Error while including bean from org.springframewrok.orm jar file in spring

I am trying to make a crud application using Spring MVC and JPA with hibernate as a service provider.I already have a working CRUD application using spring MVC and jdbc.So I decided to make changes in already built application only
But the problem is when i include any class from org.springframewrok.orm jar file in beans.xml of spring it gives me HTTP 404- resource not found error. What could be the possible reasons??
I am using org.springframewrok.orm 3.1.1 release file.

Resources