我已经运行了hibernate4 maven插件,但是在生成空输出文件之前,它没有找到带注释的类。
如果我运行目标,它会告诉我它正在扫描正确的文件夹,但它只从依赖项中找到两个类,而不是带注释的类。
[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
最佳答案
正如@Gerold Broser提到的,有一些新的版本可用。使用版本1.1.1解决了我的问题。