Spring Boot 自定义Starter 可能引发的问题(Error)
原创
©著作权归作者所有:来自51CTO博客作者信息所话事人的原创作品,请联系作者获取转载授权,否则将追究法律责任
如果你的项目出现:
Consider defining a bean of type 'com.wy.helloworld_spring_boot_starter.PersonService' in your configuration.
表示无法找到你所创建的类
问题原因: 你创建的项目非maven自定义项目,一定使用了spring initialize 创建,导入了spring boot 的父项目,
后期引入Starter 时,出现无法导入是那个类的问题,
你必须定义域一个Maven项目,并使用下面的配置
<properties>
<commonversion>2.2.5.RELEASE</commonversion>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${commonversion}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${commonversion}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${commonversion}</version>
<optional>true</optional>
</dependency>
</dependencies>