Sha*_*mik 10 java spring maven maven-shade-plugin
尝试运行可执行jar文件时,我正面临"循环占位符引用"异常.这是详细的例外.
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'postProcessProperties' defined in class path resource [applicationContext.xml]: Circular placeholder reference 'processor.core.poolsize' in property definitions
[echo] at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:287)
[echo] at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)
[echo] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663)
[echo] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:638)
[echo] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
[echo] at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
[echo] at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
[echo] at com.autodesk.postprocess.engine.PostProcessEngine.start(PostProcessEngine.java:39)
[echo] at com.autodesk.postprocess.engine.PostProcessEngine.main(PostProcessEngine.java:29)
Run Code Online (Sandbox Code Playgroud)
这是一个spring应用程序,它使用外部属性文件在启动时读取值.这是春天的定义.到目前为止,这种方法运作良好.
<bean id="propertyConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_NEVER" />
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<value>classpath:/postprocess.properties</value>
</list>
</property>
<property name="properties">
<props>
<prop key="processor.core.poolsize">${processor.core.poolsize}</prop>
<prop key="processor.max.poolsize">${processor.max.poolsize}</prop>
</props>
</property>
</bean>
<bean id="postProcessProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="processor.core.poolsize">${processor.core.poolsize}</prop>
<prop key="processor.max.poolsize">${processor.max.poolsize}</prop>
<prop key="processor.polling.delay">${processor.polling.delay}</prop>
<prop key="processor.polling.period">${processor.polling.period}</prop>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
我正在使用shade插件来生成jar文件.这是一个片段
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.7.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.test.postprocess.engine.PostProcessEngine</mainClass>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
<filters>
<filter>
<artifact>:</artifact>
<excludes>
<exclude>META-INF/.SF</exclude>
<exclude>META-INF/.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
我不确定是什么导致了这个问题,因为我之前在其他可执行jar文件中使用了类似的模式.
任何指针将不胜感激.
谢谢
Pra*_*tic 16
它可能很晚才回答这个问题,但为了面对类似问题的人的利益而加入它.
我能够通过更改密钥名称来修复它.例如
<prop key="processor.core.poolsize">${processor.core.poolsize}</prop>
<prop key="processor.max.poolsize">${processor.max.poolsize}</prop>
Run Code Online (Sandbox Code Playgroud)
改成了类似的东西
<prop key="processor.core.poolsize">${core.poolsize}</prop>
<prop key="processor.max.poolsize">${max.poolsize}</prop>
Run Code Online (Sandbox Code Playgroud)
property-placeholder键和要过滤的属性值的键不能相同.
小智 7
Circular placeholder reference XXXX in property definitions
Run Code Online (Sandbox Code Playgroud)
spring-framework当您的属性键名称和值变量名称完全相同时,将抛出上述类型的异常。
确保您的财产不应该看起来像
key={$key}. 为键和值保留不同的名称将解决此问题。
它可能无法找到资源 - postprocess.properties。你能删除这一行吗 -
<property name="ignoreResourceNotFound" value="true" />
Run Code Online (Sandbox Code Playgroud)
然后,如果未找到资源,则应显示适当的消息。
| 归档时间: |
|
| 查看次数: |
31915 次 |
| 最近记录: |