相关疑难解决方法(0)

PersistenceException:没有为持久性单元命名为default的模式生成找到持久性提供程序

我试图设置一个gradle任务,它运行一个用于生成SQL模式的java主类.

我没有persistence.xml配置文件.

这是我的配置和代码:

我的gradle任务:

task JpaSchemaExport(type: JavaExec){
       description "Exports Jpa schema"
       dependsOn compileJava
       main = "com.bignibou.tools.jpa.JpaSchemaExport"
       classpath = sourceSets.main.runtimeClasspath + configurations.compile
    }
Run Code Online (Sandbox Code Playgroud)

我的出口效用:

public class JpaSchemaExport {

    public static void main(String[] args) throws IOException {
        // execute(args[0], args[1]);
        execute("default", "build/schema.sql");
        System.exit(0);
    }

    public static void execute(String persistenceUnitName, String destination) {
        final Properties persistenceProperties = new Properties();

        // XXX force persistence properties : remove database target
        persistenceProperties.setProperty(org.hibernate.cfg.AvailableSettings.HBM2DDL_AUTO, "");
        persistenceProperties.setProperty(AvailableSettings.SCHEMA_GEN_DATABASE_ACTION, "none");

        // XXX force persistence properties : define create script target from …
Run Code Online (Sandbox Code Playgroud)

hibernate jpa hibernate-tools gradle

5
推荐指数
1
解决办法
3381
查看次数

标签 统计

gradle ×1

hibernate ×1

hibernate-tools ×1

jpa ×1