Spring Boot 自定义Starter 可能引发的问题(Error)

如果你的项目出现:

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>

猜你喜欢

转载自www.cnblogs.com/dgwblog/p/12397346.html