The profile xml/properties is distributed among the individual jar packages (keeping the application relatively independent).
The problem arises from: the original project directly pulled over, packaging, deployment, start on the error, Applicationcontext.xml can not find. It is clear that the configuration file in the jar package is not read.
Java Code Workarounds:
1,classpath:applicationcontext.xml Change to Classpath*:applicationcontext.xml
This is the same thing. Effect: Classpath*:/applicationcontext.xml
2, refer to other configuration files in Applicationcontext.xml:
If you write this in the same jar package,
Java code <import resource= "Classpath:/applicationcontext-action.xml"/>
To import the configuration files from other jar packages, write this
Java code <import resource= "Classpath*:/applicationcontext-service.xml"/>
As simple as this, repack, deploy, start successfully.
Open http://127.0.0.1:8080/portal/index.htm in the browser
Success
3,classpath two ways to use:
Classpath*:applicationcontext.xml will be added to this project and all applicationcontext.xml files in the jar package root directory, which are used across the jar package dependencies
Classpath:applicationContext.xml is only added to the Applicationcontext.xml file in the root directory of this project and is recommended when it is not dependent on the configuration files of other jar packages to avoid conflicts.
Note:
Find a common spring-based configuration:
<bean class= "Org.springframework.batch.core.configuration.support.ClasspathXmlApplicationContextsFactoryBean ">
<property name=" Resources ">
<array>
<value>classpath*:/jobs/*.xml</value >
<!--EE 7 specification---
<value>classpath*:/META-INF/batch-jobs/*.xml</value>
</array>
</property>
</bean>
This style of writing is actually based on the spring resource class, which can be used in Java
<pre style= "Background-color: #2b2b2b; color: #a9b7c6; font-family: ' Menlo '; font-size:14pt;" ><span style= "color: #cc7832;" >new </span>defaultresourceloader (). GetResource (location)