Spring启动,runnable jar无法加载package-info.class [英] Spring boot, runnable jar can't load package-info.class

查看:399
本文介绍了Spring启动,runnable jar无法加载package-info.class的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用Spring引导和hibernate数据库映射。
实体包含映射为使用 package-info.java 文件定义的自定义类型的JSON列。

We use Spring boot with hibernate database mapping. The entities contains JSON columns mapped as a customized types defined using package-info.java file.

当我们运行spring时Eclipse IDE中的项目一切正常,我们可以调用我们的Web服务。

When we run the spring-project from Eclipse IDE everything is ok and we can call our web services.

当我们生成可执行jar并尝试调用我们的Web服务时,会引发以下错误:

When we generate an executable jar and we try to call our web services the following error is raised :

mai 04, 2017 1:35:00 PM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: Unable to execute job Test] with root cause
java.lang.NoClassDefFoundError: BOOT-INF/classes/com/test/package-info (wrong name: com/test/package-info)
    at java.lang.ClassLoader.defineClass1(Native Method)

该文件package-info.class进入jar BOOT-INF / classes / com / test / package-info
有什么不对的?

The file package-info.class is into the jar BOOT-INF/classes/com/test/package-info What can be wrong ?

感谢您的帮助

推荐答案

我通过禁用包扫描和Hibernate分类的自动检测解决了这个问题

I solved this issue by disabling package scan and autodetection of classed for Hibernate

<persistence-unit name="sqlProvider" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>     
    <class>com.example.package.dao</class>

    .........     
    <properties>
        <property name="exclude-unlisted-classes" value="true"/>
        <property name="hibernate.archive.autodetection" value="hbm" />
        .........
    </properties>
    .........
</persistence-unit>

这篇关于Spring启动,runnable jar无法加载package-info.class的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆