[英]Error while starting Spring boot application with external JAR containing the beans
我有一个从 Spring 初始化程序创建的 Spring 引导应用程序,我添加了一个包含 bean 的外部 JAR (手动在构建路径库中)。 bean 用@Entity 和@json 注释...问题是在启动应用程序时出现以下错误。 如果我将 bean 作为一个简单的 bean 复制到项目中,项目将正确启动。
创建名为“userRepository”的 bean 时出错:调用 init 方法失败; 嵌套异常是 java.lang.IllegalArgumentException:不是托管类型:class org.xxxxxxx.domain.User
非常感谢任何帮助
这是来自 JAR 的 bean 示例。
package org.xxxxxxx.domain;
import java.io.Serializable;
import java.sql.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
@Entity
@Table (name="userTable", uniqueConstraints=@UniqueConstraint(columnNames={"nom"}))
public class User implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@Column(name="nom", unique=true, nullable=false)
private String name;
private String motsdepasse;
private String token;
@ManyToOne
private UserGroupe groupe;
// @Column(columnDefinition="boolean default false")
private boolean desactive;
// @Column(columnDefinition="boolean default false")
private boolean finalPwd;
private boolean deleted;
private Date datePassword;
@ManyToOne
private Branch branche;
//getters + setters
默认情况下,将搜索主配置 class(带有 @EnableAutoConfiguration 或 @SpringBootApplication 注释的那个)下的所有包。 您可以使用 @EntityScan 注释自定义实体扫描位置:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.