javaspringspring-bootspring-boot-starter

Why doesn't my Spring Boot starter bring its dependencies to the project?


I've created a simple starter - TimeStarter with RestController inside. Here is its pom:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.5.0</version>
    <relativePath/>
</parent>

<groupId>ez</groupId>
<artifactId>time-starter-spring-boot-starter</artifactId>
<version>0.0.1</version>
<name>time-starter</name>

<properties>
    <java.version>11</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <optional>true</optional>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>

I've added TimeStarter to my project:

<dependencies>
    <dependency>
        <groupId>ez</groupId>
        <artifactId>time-starter-spring-boot-starter</artifactId>
        <version>0.0.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

After that I expect that all necessary dependencies (spring-boot-starter-web) will appear in my project, and the REST controller from starter will be ready for HTTP requests. But no, I have to add spring-boot-starter-web and spring-web dependencies to make my starter work.


Solution

  • As M.Deinum said, the reason was I made my dependencies in starter "optional".