1

我正在尝试使用 OSGI 包中的 org.springframework.jdbc.core.JdbcTemplate 连接 oracle 数据库。在 servicemix 中部署 bundle 时,它​​显示错误

org.osgi.framework.BundleException:捆绑我的第二个服务 [376] 中未解决的约束:无法解析 376.0:缺少要求 [376.0] 包;(包=org.springframework.jdbc.core)

这是我的 pom 文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>com.my.service</groupId>
    <artifactId>my-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>../my-service/pom.xml</relativePath>
</parent>

<groupId>com.brodos.osgi</groupId>
<artifactId>my-second-service</artifactId>
<packaging>bundle</packaging>
<version>0.0.1-SNAPSHOT</version>

<name>My Second Service</name>
<url>http://example.net</url>

<dependencies>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.2.0.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring</artifactId>
        <version>2.8.0-fuse-01-13</version>
    </dependency>
    <dependency>
        <groupId>springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>1.2.1</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <version>1.4.3</version>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>My Second Service</Bundle-SymbolicName>
                    <Bundle-Description>My Second Service</Bundle-Description>
                    <Import-Package>
                        org.apache.servicemix.camel.nmr,
                        org.apache.servicemix.nmr.api,
                        org.apache.servicemix.nmr.api.event,
                        org.apache.servicemix.nmr.api.internal,
                        *
                    </Import-Package>
                    <Private-Package>com.test.osgi.*</Private-Package>
                    <Include-Resource>src/main/resources</Include-Resource>
                    <DynamicImport-Package>*</DynamicImport-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

4

2 回答 2

1

您需要安装导出包的org.springframework.jdbc.core包。

于 2012-02-15T13:14:26.347 回答
1

Jignesh,这可能值得一看:

从ebr.springsource.com下载这个 jar :

由于您处于 OSGi 环境中,因此您还需要其他捆绑包,例如org.springframework.osgi.core org.springframework.osgi.ioorg.springframework.osgi.extender. 这些还需要一些额外的捆绑包,例如org.apache.commons. 您可能需要稍微摆弄一下 MANIFEST.MF 以匹配版本以使其运行。

查看本教程以获得一个想法:我能够导入并运行它。

注意*到目前为止,我正在手动进行此集成...我希望使用 maven,因为事情对我来说很清楚。

于 2013-05-16T20:52:55.680 回答