我试图将一个属性文件读入confluence插件中的spring上下文。我已将META-INF / spring添加到以下上下文文件中:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:atlassian-spring="http://www.atlassian.com/schema/atlassian-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.atlassian.com/schema/atlassian-spring http://www.atlassian.com/schema/atlassian-spring/atlassian.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="db.properties"/>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="url" value="${db.url}" />
<property name="driverClassName" value="${db.driver}" />
<property name="username" value="${db.user}" />
<property name="password" value="${db.password}" />
</bean></beans>
另外,对于pom.xml,我添加了以下依赖项:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>2.5.6.SEC02</version>
<scope>provided</scope>
</dependency>
不幸的是,我一直在为PropertyPlaceholderConfigurer获取ClassNotFoundException。 据我所知,这是一个OSGi问题 - 因为该类没有被代码引用,所以它不是由OSGi添加的。 这里:https://developer.atlassian.com/display/DOCS/ClassNotFoundException我发现我应该在atlassian-plugin.xml中将import-Package添加到spring beans包中,但是添加了这个:
<bundle-instructions>
<Import-Package>org.springframework.beans*</Import-Package>
</bundle-instructions>
没有帮助。 有什么建议吗?
答案 0 :(得分:0)
上面提到的Spring版本有OSGI包吗?你确定吗?因为某些spring版本没有OSGI包。在这种情况下,您需要自己转换为捆绑包。如果它不是OSGI包。包裹不会暴露,类无法找到,因此你得到上述错误。
关于spring OSGI捆绑包的一些细节。
http://ebr.springsource.com/repository/app/
http://www.srikanthugar.in/2014/04/sspring-framework-is-no-longer.html
http://www.srikanthugar.in/2014/04/how-to-convert-spring-beans-artifact-to.html
答案 1 :(得分:0)
我找到了问题的答案。为了在汇合中配置OSGI,应该配置maven插件:
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-***-plugin</artifactId> <!-- *** is the name of the application (product) you're using -->
<version>3.2.3</version>
<extensions>true</extensions>
<configuration>
<productVersion>${product.version}</productVersion>
<instructions>
<!-- OSGi instructions go here -->
</instructions>
</configuration>
</plugin>
并将Import-Package声明放在那里。