码迷,mamicode.com
首页 > 编程语言 > 详细

Idea开发环境中,开发springboot类型的项目,如果只引入parent节点,不添加依赖节点,maven是不会加载springboot的任何依赖的

时间:2019-06-18 21:30:41      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:port   star   左右   关闭   使用   其他   tar   pen   想法   

在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。

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

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

 

Idea开发环境中,开发springboot类型的项目,如果只引入parent节点,不添加依赖节点,maven是不会加载springboot的任何依赖的

标签:port   star   左右   关闭   使用   其他   tar   pen   想法   

原文地址:https://www.cnblogs.com/wangqiideal/p/11047879.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!