Watch for Dependency Name Typos When Creating New Spring Boot Projects
The trouble with CLI... This article helps you avoid a possible pitfall when creating new Spring Boot projects from Spring Boot CLI.
Join the DZone community and get the full member experience.Join For Free
If you use the Spring Boot CLI, it’s pretty easy to get a new project created from the templates with all required dependencies in place with something like:
spring init --build=maven --dependencies=web project-name.zip
This generates you a zip that you can unzip and import into your IDE and off you go. The trouble with the CLI currently though is that there’s no validation on the dependency names, so if you call
spring init --build=maven --dependencies=wb project-name.zip
You’ll get the same zip generated, but there will be a subtle typo in your dependencies which unless you’ve seen these messages from maven before, you’ll spend a bunch of time trying to work out what’s wrong.
I created a ticket for this issue here, and hopefully this gets picked up as an enhancement.
The maven error in case you’re interested looks like this:
[INFO] Scanning for projects... [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project com.example:testbaddep:0.0.1-SNAPSHOT (/Users/kev/develop/spring-boot/testbaddep/pom.xml) has 1 error [ERROR] 'dependencies.dependency.version' for org.springframework.boot:spring-boot-starter-wb:jar is missing. @ line 27, column 15 [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
Published at DZone with permission of Kevin Hooke, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.