小编Pet*_*ann的帖子

Liquibase 不创建基于 JPA 实体的差异变更日志

我试图在已经提出的问题以及一些用户推荐的这篇文章中找到答案:http : //www.operatornew.com/2012/11/automatic-db-migration-for-java-web.html但没有运气好的话。

问题是我使用 Maven 构建工具和 Postgres DB 为我的 Java 项目完整配置了 Liquibase,但即使我已经定义了 Hibernate 实体,Liquibase diff也没有考虑它们,并且不会基于 JPA 注释实体生成变更锁.

我尝试了所有方法,但使用空的changelock-master.xml并定义了 2 个实体,结果diff.xml为空。

这是我的pom.xml

        <!--LIQUIBASE-->
        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>3.4.1</version>
        </dependency>
        ...
        <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>3.5.3</version>
                <dependencies>
                    <dependency>
                        <groupId>org.liquibase.ext</groupId>
                        <artifactId>liquibase-hibernate4</artifactId>
                        <version>3.6</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-beans</artifactId>
                        <version>4.1.7.RELEASE</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework.data</groupId>
                        <artifactId>spring-data-jpa</artifactId>
                        <version>1.7.3.RELEASE</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <propertyFile>src/main/resources/liquibase.properties</propertyFile>
                    <changeLogFile>src/main/resources/db/changelog/changelog-master.xml</changeLogFile>
                </configuration>
            </plugin>
Run Code Online (Sandbox Code Playgroud)

在这里,我定义了liquibase.properties

referenceUrl=hibernate:spring:com.victus.applied.entity?dialect=org.hibernate.dialect.PostgreSQLDialect
referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
referenceUsername=testusername
referencePassword=
driver=org.postgresql.Driver
url=jdbc:postgresql://localhost:5432/applied
username=testusername …
Run Code Online (Sandbox Code Playgroud)

java hibernate jpa liquibase

2
推荐指数
1
解决办法
3194
查看次数

ValidationException:接口未定义有效的远程业务接口; 该方法不符合RMI规则

启动EJB应用程序时,我在IBM WebSphere Application Server上遇到以下异常:

com.ibm.wsspi.amm.validate.ValidationException:接口 YourInterface没有定义有效的远程业务接口; 方法yourMethod不符合RMI规则

我检查了Oracle的文档中的RMI确认规则,但这没有用.我还发现IBM问题票据描述了我的问题,但是通过设置一个未记录的JVM属性来提供一个模糊的解决方案 - 这也不起作用.

ejb rmi java-ee

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

ByteArrayOutputStream.toByteArray()返回随机字节?

我正在尝试为我重构的方法编写一个Junit测试,以确保该方法仍然按预期运行.我注意到一些我无法弄清楚的奇怪行为.

为什么Java ByteArrayOutputStream.toByteArray()会返回一些随机字节?我想这可能与记忆有关.数组中的11个字节始终是随机的.任何见解?

这是我重构的方法.

package foo;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class ZipUtil {

    public static byte[] createZip(Map<String, byte[]> files) throws IOException {
        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
        final ZipOutputStream zipfile = new ZipOutputStream(bos);
        String fileName = null;
        ZipEntry zipentry = null;
        for (Map.Entry<String, byte[]> entry : files.entrySet()) {
            fileName = entry.getKey();
            zipentry = new ZipEntry(fileName);
            zipfile.putNextEntry(zipentry);
            zipfile.write(files.get(fileName));
        }

        zipfile.close();  
        return bos.toByteArray();  
    }  
}
Run Code Online (Sandbox Code Playgroud)

测试类

package foo;

import …
Run Code Online (Sandbox Code Playgroud)

java zip bytearray java-io

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

PHP中的OOP问题

我有以下代码:

class the_class {
  private the_field;

  function the_class() {
    the_field = new other_class(); //has other_method()
  }

  function method() {
    $this->the_field->other_method(); //This doesn't seem to work
  }
}
Run Code Online (Sandbox Code Playgroud)

这里的语法有什么问题吗?方法调用似乎总是返回true,就好像方法调用有问题一样.或者方法调用是否正确,我应该调试other_method()本身?

TIA,彼得

php oop syntax

-1
推荐指数
1
解决办法
112
查看次数

标签 统计

java ×2

bytearray ×1

ejb ×1

hibernate ×1

java-ee ×1

java-io ×1

jpa ×1

liquibase ×1

oop ×1

php ×1

rmi ×1

syntax ×1

zip ×1