I'm trying to use @ImportResource annotation import on different environment config files like reported below:
@EnableFeignClients
@EnableAsync
@ImportResource(locations= {"classpath:${dev|sit}/service-applicationContext.xml","classpath:${dev|sit}/client-applicationContext.xml"})
public class DmrEsbService {
}
Or I'm trying to use other ways to import properties like spring.profiles.active=test, as I reported below:
@Value("${spring.profiles.active}")
public String env;
@Autowired
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
synchronized (lock) {
if (null == ESBClientFactory.applicationContext) {
String[] profiles = {"/profiles/" + env + "/client-applicationContext.xml", "/profiles/" + env + "/service-applicationContext.xml"};
ESBClientFactory.applicationContext = new ClassPathXmlApplicationContext(profiles, applicationContext);
}
}
}
but by using this last way to startup the app, it happened like below:
2021-12-10 15:04:16.005 - [<init> 122] - [INFO] - To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2021-12-10 15:04:16.027 - [getInstance 281] - [INFO] - DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@1fdc92b
2021-12-10 15:04:17.795 - [refresh 554] - [WARN] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'publicQueryService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.xxxx.oracle.xmlns.apps.cux.soaprovider.plsql.cux_esb_mass_query_pkg.CUXESBMASSQUERYPKGPortType' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
2021-12-10 15:04:17.810 - [log 173] - [INFO] - Stopping service [Tomcat]
2021-12-10 15:04:17.917 - [logMessage 142] - [INFO] -
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-12-10 15:04:17.917 - [deregister 65] - [INFO] - Unregistering application xxxx with eureka with status DOWN
2021-12-10 15:04:17.918 - [shutdown 888] - [INFO] - Shutting down DiscoveryClient ...
2021-12-10 15:04:17.925 - [shutdown 911] - [INFO] - Completed shut down of DiscoveryClient
2021-12-10 15:04:18.225 - [report 42] - [ERROR] -
***************************
APPLICATION FAILED TO START
***************************
Description:
A component required a bean of type 'com.xxx.oracle.xmlns.apps.cux.soaprovider.plsql.cux_esb_mass_query_pkg.xxx' that could not be found.
Action:
Consider defining a bean of type 'com.xxx.oracle.xmlns.apps.cux.soaprovider.plsql.cux_esb_mass_query_pkg.xxx' in your configuration.
I could not use the command below to package an app:
mvn clean -Dmaven.test.skip=true package -pl xxx -am -Psit
and then I'm using the following:
mvn clean install
could anyone who can tell to how to import different environment in my project?