I have one Spring Boot application that uses Bazel to manage all of its dependencies, that I migrated from Maven.
I'm able to launch the app using Bazel, but after checking all of its beans I noticed that are missing the beans of the classes that I created using the #Component, #Service and #Repository annotations.
If I use Maven, these beans are added to the Application context as expected.
Is something missing in my Bazel configuration? How can I generate and add these beans to my application context?
Related
I added the modules that I want to test as dependency, I try to create a #SpringBootTest but it can't find my #SpringBootApplication class thats inside a dependency. What's the best approach here?
Suppose we have a Spring application (say using Gradle or Maven).
We control a Maven dependency which imports various spring boot starters and configures them (using #Configuration and application*.yml files).
When does the imported configuration apply? If the application defines its own application.yml, what are the rules for determining which configuration “wins” over the over?
I'm in the midst of upgrading an app from Spring Boot 1.x to Spring Boot 2.x. When I attempted to run an existing (and previously working) unit test, I saw the following output:
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'spring.sleuth.baggage-keys', defined in class path resource [org/springframework/cloud/sleuth/autoconfig/brave/BraveBaggageConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/cloud/sleuth/autoconfig/TraceBaggageConfiguration.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
My Gradle project uses the following implementation: 'org.springframework.cloud:spring-cloud-sleuth-core:2.2.8.RELEASE'
I tried checking with the Gradle dependencies task to make sure there were no conflicting versions of spring-cloud-sleuth-core and friends. I also looked at this post and this post and they didn't solve my problem.
I need to avoid overriding beans, and I'm currently constrained to Spring Boot 2.4.x for my deploy target.
Check the compatibility matrix, you should use Spring Cloud 2020.0.x aka Ilford (Sleuth 3.x) with Spring Boot 2.4 (or 2.5).
Sleuth 2.2.8 is Spring Cloud Hoxton, it is not compatible with Boot 2.4.
I want to add a project as a dependency to a Spring boot project.
I can't use a maven multimodule approach.
Now in this project I'm exposing a service that is sending queries to a Database. The Database connection data needs to be set from the main Project application.properties.
How can I access the data from the main project? Should I use Spring in the "dependency project" too?
Could you point me in the right direction ? Is this even possible?
Any help is greatly appriciated.
Thanks!!
I solved this problem in a very very convinient way.
I developed my service with a spring boot application + spring-data. When I was done with this service (development testing etc.) I packaged it as a jar.
This jar included only the models, repositories and the services. All Spring configurations have been excluded.
I added this jar as a dependency to my other Spring boot project and changed my #EntityScan and #EnableJpaRepositories to include the packages from the dependency.
My annotations look like this now:
#....
#EntityScan("my.package.entities", "dependency.package.entities")
#EnableJpaRepositories("my.package.repositories", "dependency.package.repositories")
#....
public class JpaConfiguration extends BaseJpaConfiguration
My dependency models and repositories used automatically the spring configuration from the parent project.
I don't know if this is the best way to go about this, I only have a little experience with spring.
If you have any advice to do this in a better way, please write it here.
Thanks for woatching.
I wanted to do spring junit testing to be implemented in my project, I am facing an issue. 1.I wanted a scenario where i can use one spring version jars for junit(src/test) and another spring version of jars for the running main java class(src/main) is it possible. I mean when spring is in testing phase it should use the spring 3.2.4.release and while building the ear it should use 3.0.5.release jars. is it possible.2.since the project is in 3.0.5.release and we wanted to use #WebAppConfiguration for testing which is not allowed in spring 3.0.5.release is there any way to do this (#WebAppConfiguration) in spring 3.0.5.release