当我尝试导出我的独立应用程序时,我遇到了问题。
当我使用eclise执行它时运行正常,但是当我尝试导出到可运行的jar时它会给我一些错误。
我的persistence.xml看起来像
<persistence-unit transaction-type="RESOURCE_LOCAL" name="alctel_server_monitor">
<provider>org.hibernate.ejb.HibernatePersistenceProvider</provider>
<class>br.com.monitor.database.vo.Servidor</class>
<class>br.com.monitor.database.vo.Banco</class>
<class>br.com.monitor.database.vo.Servico</class>
<class>br.com.monitor.database.vo.alerta.Alerta</class>
<class>br.com.monitor.database.vo.alerta.AlertaAtivo</class>
<class>br.com.monitor.database.vo.email.Email</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.connection.driver_class" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="hibernate.connection.url" value="jdbc:sqlserver://192.168.99.222;databaseName=MONITOR;" />
<property name="hibernate.connection.username" value="" />
<property name="hibernate.connection.password" value="" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />
<property name="hibernate.hbm2ddl.auto" value="none" />
<property name="hibernate.hbm2ddl.import_files_sql_extractor"
value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" />
<property name="hibernate.connection.useUnicode" value="true" />
<property name="hibernate.connection.characterEncoding"
value="UTF-8" />
</properties>
</persistence-unit>
它位于src / META-INF / persistence.xml
我从终端运行时获得的堆栈跟踪是:
at java.lang.reflect.Method.invoke(Unknown Source) 在org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58) 引起:javax.persistence.PersistenceException:无法找到持久性单元 在org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:99) 在org.hibernate.ejb.HibernatePersistence.getEntityManagerFactoryBuilderOrNull(HibernatePersistence.java:93) 在org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:86) 在org.hibernate.ejb.HibernatePersistence.getEntityManagerFactoryBuilderOrNull(HibernatePersistence.java:101) 在org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:67) 在org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54) 在javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
我不知道发生了什么,有人可以帮助我吗?
谢谢!
答案 0 :(得分:0)
我遇到了同样的问题,我通过以下方式解决了问题:
右键单击项目&gt;属性&gt; Java构建路径&gt;订单和导出,并选择库
右键单击项目&gt;导出...&gt; Runnable JAR文件&gt;将所需的库复制到生成的JAR旁边的子文件夹