【发布时间】:2018-08-27 16:56:44
【问题描述】:
我有使用 SQLite 数据库的应用程序。 我把它打包成一个包,我可以看到服务组合上的服务。 当我向 Post 或 Get 服务发送请求时,我收到此错误:
java.lang.ClassNotFoundException: org.sqlite.JDBC 未找到
我在 servicemix 上安装了 SQLite JDBC 驱动程序,但仍然出错。
这是我的 POM:
<modelVersion>4.0.0</modelVersion>
<groupId>asd</groupId>
<artifactId>name</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Name</name>
<description>Bundle Desc</description>
<dependencies>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.15.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
<version>3.1.5</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.3.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Description>${project.description}</Bundle-Description>
<Import-Package>
javax.jws,
javax.wsdl,
javax.xml.namespace,
org.apache.cxf.helpers,
org.osgi.service.blueprint,
org.xerial.sqlite-jdbc,
*
</Import-Package>
<Export-Package>
my.services.package,
org.xerial.sqlite-jdbc
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
我试图把这个 org.xerial.sqlite-jdbc 只作为一个导出包和只作为一个导入包但没有成功。
这是 SQLite 连接的 java 代码:
private void getConnection() throws ClassNotFoundException, SQLException {
Class.forName("org.sqlite.JDBC");
con = DriverManager.getConnection("jdbc:sqlite:SQLiteTest1.db");
initialise();
}
应用程序在本地运行,但在 servicemix 上不运行。
【问题讨论】:
-
访问sqlite的java代码是什么?
-
我编辑了这个问题。谢谢!
标签: java jdbc osgi osgi-bundle apache-servicemix