liquibase - 是否可以将两个包与jpa注释类进行比较?如何?

时间:2015-06-05 14:58:03

标签: spring hibernate maven jpa liquibase

我在我的spring hibernate应用程序中使用liquibase-hibernate-extension和maven。 我想将我的jpa / hibernate注释类的旧版本与较新版本进行比较(例如,使用相同的软件包,没有ImprovedNamingStrategy)。在我的pom.xml中就像这样:

<url>hibernate:spring:com.myc.model?dialect=org.hibernate.dialect.PostgreSQLDialect</url> 
<referenceUrl>hibernate:spring:com.myc.model?hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy&amp;dialect=org.hibernate.dialect.PostgreSQLDialect</referenceUrl>

我开始&#39;这个例外:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.3.2:diff (default) on project model: Error setting up or running Liquibase: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL: class path resource [] cannot be resolved to URL because it does not exist -> [Help 1]

因此,如果我在pom.xml中使用它作为url,一切都很完美:

<url>jdbc:postgresql://localhost/mydb</url>
<driver>org.postgresql.Driver</driver>
<username>user</username>
<password>pass</password>
<referenceUrl>hibernate:spring:com.myc.model?hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy&amp;dialect=org.hibernate.dialect.PostgreSQLDialect</referenceUrl>

所以可以使用hibernate:spring作为url的前缀,我该如何管理呢?

我已经读过这个:Compare two hibernate mapping files

我认为这应该是可能的!

感谢您的回答!

更新

命令行工具与上面的设置完美配合。只有maven插件会遇到所描述的错误。 完整Stacktrace:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.3.2:diff (execution1) on project model: Error setting up or running Liquibase: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Caused by: org.apache.maven.plugin.MojoExecutionException: Error setting up or running Liquibase: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
    at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:373)
    at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.execute(LiquibaseDatabaseDiff.java:145)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 20 more

Caused by: liquibase.exception.DatabaseException: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:69)
    at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:321)
    ... 23 more

Caused by: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:591)
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:443)
    at liquibase.ext.hibernate.database.HibernateSpringDatabase.buildConfigurationFromScanning(HibernateSpringDatabase.java:227)
    at liquibase.ext.hibernate.database.HibernateSpringDatabase.buildConfiguration(HibernateSpringDatabase.java:55)
    at liquibase.ext.hibernate.database.HibernateDatabase.setConnection(HibernateDatabase.java:45)
    at liquibase.database.DatabaseFactory.findCorrectDatabaseImplementation(DatabaseFactory.java:123)
    at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:143)
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:50)
    ... 24 more

Caused by: java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
    at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:187)
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:588)
    ... 31 more

0 个答案:

没有答案