执行 OSGi 包时遇到问题“/hibernate.cfg.xml not found”。我通过 Apache felix bundle 插件创建了一个 OSGi 包,在我的包中我通过休眠连接数据库。当我在 OSGi 容器中执行我的包时,它会引发错误。我已经通过捆绑包根文件夹中的 POM.xml 文件中的资源标记添加了所有与休眠相关的 xml 文件(如 hibernate.cfg.xml)。
错误是
SessionFactory 创建失败:org.hibernate.HibernateException: /hibernate.cfg.xml not found
这可能是小问题,但我无法弄清楚,请帮助我解决问题
这是我的 POM.xml 文件
……………………………………………………………………………………………… ……………………………………………………………………………………………………………………
<build>
<sourceDirectory>D:\WSNew\HCB-VCDPlugin100\src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.5</version>
<extensions>true</extensions>
<configuration>
<excludeDependencies>*;scope=provided|runtime</excludeDependencies>
<instructions>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Directory>OSGI-INF/lib</Embed-Directory>
<Embed-Transitive>true</Embed-Transitive>
<!-- Export-Package>${project.exports}</Export-Package> -->
<!--<_exportcontents>${project.exports}</_exportcontents> -->
<Import-Package>org.osgi.framework, ,org.apache.log4j,org.hibernate,org.hibernate.cfg,org.hibernate.transform,org.quartz,org.quartz.impl,javax.xml.transform,org.w3c.dom,org.xml.sax,javax.xml.parsers,!*</Import-Package>
<Bundle-Activator>com.abclcorp.hcb.vddservice.impl.Activator</Bundle-Activator>
<!-- <Private-Package>org.foo.myproject.*</Private-Package> -->
<_exportcontents>*</_exportcontents>
</instructions>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>resources/configuration</directory>
<includes>
<include>CronScheduler.xml</include>
</includes>
</resource>
<resource>
<directory>resources/log4j</directory>
<includes>
<include>log4j.properties</include>
</includes>
</resource>
<resource>
<directory>resources/logs</directory>
<includes>
<include>CronScheduler.log</include>
</includes>
</resource>
<resource>
<directory>src</directory>
<includes>
<include>*.xml</include>
</includes>
</resource>
</resources>
</build>