Question
What are the steps to fix the 'Dependency org.springframework.boot:spring-boot-starter-web:2.3.0.RELEASE not found' error in a Spring Boot project?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.3.0.RELEASE</version>
</dependency>
Answer
The error 'Dependency org.springframework.boot:spring-boot-starter-web:2.3.0.RELEASE not found' occurs when Maven cannot locate the specified version of the Spring Boot starter dependency in its repositories. This can happen due to several reasons, such as incorrect repository settings or the specified version not existing.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.3.0.RELEASE</version>
</dependency>
</dependencies>
Causes
- The specified version of the Spring Boot starter does not exist in Maven Central or other defined repositories.
- Network issues preventing access to Maven repository.
- The repository settings in your `pom.xml` or settings.xml are incorrect, leading to the inability to locate necessary artifacts.
Solutions
- Ensure you are connected to the internet and try refreshing your Maven project.
- Check the `pom.xml` file to ensure that the version for `spring-boot-starter-web` is correct.
- Verify that you have the correct repositories configured in your `pom.xml` or settings.xml. You can specify Maven Central explicitly if it's missing: <repositories> <repository> <id>central</id> <url>https://repo.maven.apache.org/maven2</url> </repository> </repositories>
- Try updating to a newer version of Spring Boot that is available. You can find the latest version on the [Spring Boot releases page](https://spring.io/projects/spring-boot#learn).
- Run `mvn clean install` to clear and rebuild your project.
Common Mistakes
Mistake: Using a non-existent version of the dependency.
Solution: Always check available versions of the dependency in the Maven Central Repository before specifying.
Mistake: Not refreshing the Maven project after changes.
Solution: Use the command `mvn clean install` or refresh your IDE's project structure to update dependencies.
Helpers
- spring boot dependency not found
- org.springframework.boot:spring-boot-starter-web not found
- fix spring boot starter web dependency
- maven dependency issue
- spring boot troubleshooting