Possible to use Spring Boot 1.3.0.M1 with Spring Cloud? - spring-boot

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.

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

Spring Boot - configure properties of a jar included as dependency into another jar

I have a Spring Boot web app A and its dependent on a Spring Boot jar library B. I have some properties that I want to configure within B and don't want the client apps (e.g. the web app A) to configure them. I have these properties files in B.
application-dev.properties
application-stage.properties
applicatino-live.properties
The issue is that these properties are not recognized when the library is added as a dependency in web app A. What is the way to achieve this?
The PropertySource annotation can be used in a Configuration class on webapp A to achieve what you're looking for:
#Configuration
#PropertySource("classpath:application-dev.properties"),
#PropertySource("classpath:application-stage.properties"),
#PropertySource("classpath:application-live.properties")
public class WebappAConfiguration {
}
I also found the order that spring boot looks for externalized configuration helpful here.

In Spring Boot 2.1.3 not able to exclude Couchbase Auto Configuration

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.

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

Migrating an existing spring jersey servlet2.5, Jersey2.3 webapp to springboot

Evaluating to port an existing mid to large sized multi module JEE application, this consists servlet 2.5, Jersey for rest and Spring 3.2.9 (JDK8, Maven 3. currently we build a war file and deploy it on to aws. My objective for this exercise is to be able to use spring-boot to create a self contained executable jar that can be installed on AWS and this would help us just run on cloud with java -jar
Is it possible to use spring boot considering the project is not using spring-web module, it is more traditional Servlet2.5 statically declaring all servlets and filters in web.xml
which approach is better, adding spring boot as a parent or dependency.
Any experience and info our senior spring community members have in this kind of migration.
This is absolutely possible to do even if you're not using Spring Web MVC.
You can use spring-boot-starter-parent like a BOM POM, so you can import its dependencies without having to change your POM's parent.
Take a look at the Spring Boot documentation for migrating a web.xml application to Spring Boot. The main points here for traditionally deployed servlets and filters are:
A #Bean of type Servlet or ServletRegistrationBean installs that bean
in the container as if it was a <servlet/> and <servlet-mapping/> in
web.xml.
A #Bean of type Filter or FilterRegistrationBean behaves
similarly (like a <filter/> and <filter-mapping/>.

Resources