read properties from third party jar in spring boot application - spring-boot

I’m adding a third party jar as a maven dependency in my spring boot application A. Third party jar is a jar of another spring-boot application B. it has its own configurations saved in conf folder "B.properties".
I have used #Import({B.class}) annotation to import the beans of application B in my application but not able to access the configuration properties of application B. Is there any way to access the configuration properties of an application from a jar?

You can create your own Config Server just add #EnableConfigServer annotation and provider configurations from service A to service B.
You can review this example:
https://spring.io/guides/gs/centralized-configuration/
UPDATED Fix adding
#PropertySource("classpath:/conf/B.properties"),

Related

Is there any way to create a spring boot jar file and deploy in any application either in Spring or Struts application to trace the request/response?

Team,
I want to develop a spring boot application jar file and that jar file I can deploy in any application as a library and that our custom jar file can use to store user's request and response in the database?

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.

How to add class with #resource annotation from a dependancy JAR to spring-boot application

i have two projects one for cache and other to use it. I have added the dependency of cache project as jar in my spring-boot application. but the classes mentioned with #Resouce i am not able to access in my spring boot application. how to resolve it?

Separate properties for a shared spring library contained inside a spring boot application

I created a shared library in spring that I deploy as an artifact in an artifactory. I use this shared library artifact in another spring boot application as a pom dependency. Shared library has it's own properties files under src/main/resources
I am having problems with the following:
When I try to load the spring boot application, it is not able to load the properties for the shared library and expects all the properties shared library needs in the outer spring boot application. How can fix this and have shared library always read its own properties file ?
Use #PropertySource annotation to provide the two sources for your app:
#PropertySources({
#PropertySource("classpath:yourSharedLib.properties"),
#PropertySource("classpath:youApp.properties")
})

Maven Pom Update

I am using Spring Tool Suite (STS) for my Spring boot application development.
I am using the Spring Started Project option to select the component required for my applications. For example: if I want to develop web application, I will select the "web" check box and spring io initailzier will download all the required jars in the classpath with help of maven.
Suppose, after the project creation for WEB, If I want to add some other components in my existing web project like using Eureka, Hystrix, the required jars are not automatically setup in the classpath and couldn't use the annotation like #EnableEurekaClient as it throws error as jar is missing.
I have manually updated the pom.xml to include the Eureka starter/client/server dependency and trying to update the project (Project >> Maven >> Update Project), so that required jars will be in classpath. But it is not happening.
Any advise on it..thanks.

Resources