在SpringBoot类型的项目中,我本来是要使用pringBoot,创建一个Console项目,我原本在pom.xml中添加paren节点了,天真的认为不需要再添加其他任何依赖了,可是接下来的1个小时左右,我彻底的承认,我错了,错的很离谱:

参见:基于 Spring Boot 编写控制台程序

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.RELEASE</version>
    </parent>
    <groupId>net.cnki.console2</groupId>
    <artifactId>appconsole</artifactId>
    <version>1.0-SNAPSHOT</version>

</project>

因为我是搞测试项目,想测试基于springboot的console项目,结果死活在依赖中都看不到springboot相关的jar包,无论我怎么操作File->Maven->Reimport,因为我不需要依赖 spring-boot-starter-web  的jar包,所以我没有引入这个依赖模块

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

 

因为,我一直自我认为,只要引入parent节点,就能自动引入springboot的一系列jar包,是我想多了,害的我反复关闭idea,重启电脑,都无济于事。后来,我测试引入其他的依赖包,与springboot无关的,我发现可以自动导入依赖。突然,我好像明白了什么,至少需要引入一个有关springboot的依赖包,比如引入一个  spring-boot-starter-webspring-boot-starter-web。

这个坑看来躲不过,今天跳了,真的很无语!

请有相同想法的人,绕坑走!

 

posted on 2019-06-18 21:18  踏歌&而行  阅读(3246)  评论(0编辑  收藏  举报