Spring Boot(3)---自定义spring boot starter 问题

1. "Failed to process import candidates for configuration class [com.simple.....]":

主要原因:

是因为自己定制的starter在打包时(package)用了spring-boot-maven-plugin,即在你的定制starter工程的pom.xml中有如下配置:

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

这样打出的包,就是按着spring boot的打包方式,Classpath设定,相对目录,资源目录等。当你用另一个spring boot项目使用这个定制的starter的jar包时。就会有问题 ,因为认为你这个starter是一个普通的jar包。

这样就无法找到你的类定义。

解决办法:

删除自定义starter中的pom.xml中的打包插件设置,采用缺省的jar打包方式。即可解决这个问题。

2.java.lang.IllegalArgumentException: Not an managed type: class .... ”

根本原因:

是你用到的一些JPA,实体,及Repository类不是你spring boot启动文件所在的目录。导致JPA搜不到这些实体,Repository类。

解决办法:

在spring boot 的启动类中加入如下注解:

@EnableJpaRepositories("com.example.repository")//那些搜索不到的JPA相关的实体及Repository的包路径

@EntityScan("com.example.repository")

如果你用到了mongo的JPA还应该加上相对应的。

@EnableMongoRepositories("com.example.mongo")
@EnableJpaRepositories("com.example.repository")

@EntityScan("com.example.repository")

 

转载于:https://www.cnblogs.com/windwithlife/p/5947327.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值