我正在运行hibernate4-maven-plugin,但是它找不到我的注释类,因此没有生成一个空的输出文件。
如果我运行目标,它会告诉我它正在扫描正确的文件夹,但只能从依赖项中找到两个类,而不能从我的注释类中找到。
[DEBUG] Detected classes with mapping-annotations:
[DEBUG] org.springframework.data.jpa.domain.AbstractAuditable
[DEBUG] org.springframework.data.jpa.domain.AbstractPersistable
我的课:
package ch.tbz.schooltool.schooltoolbackend;
import ch.tbz.schooltool.schooltoolbackend.person.Gender;
import ch.tbz.schooltool.schooltoolbackend.person.Role;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.time.LocalDate;
@Entity
@Table(name = "PERSON")
@Data
@NoArgsConstructor
@EqualsAndHashCode(of = "id")
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "person_id_seq")
@SequenceGenerator(name = "person_id_seq", sequenceName = "person_id_seq", allocationSize = 1)
Integer id;
String firstName;
String lastName;
@Enumerated(EnumType.STRING)
Gender gender;
LocalDate dateOfBirth;
@Enumerated(EnumType.STRING)
Role role;
}
我的POM插件:
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate4-maven-plugin</artifactId>
<version>1.0.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
<configuration>
<hibernateProperties>${project.basedir}/schooltool-db/hibernate.hbm2ddl.properties
</hibernateProperties>
<outputFile>${project.basedir}/schooltool-db/create_ddl_generated.sql</outputFile>
<target>SCRIPT</target>
<type>CREATE</type>
</configuration>
</plugin>
我的配置:
hibernate.dialect=org.hibernate.dialect.PostgreSQL81Dialect
hibernate.connection.charSet=UTF-8
hibernate.export.schema.delimiter=;
hibernate.id.new_generator_mappings=true
hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy
答案 0 :(得分:1)
正如@Gerold Broser所述,有较新的版本可用。使用1.1.1版解决了我的问题。