`
gaojingsong
  • 浏览: 1182055 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

那些年Intellij Idea踩过的坑

 
阅读更多

     在 Intellij Idea  中使用maven时,所有 scope 为 provided 的依赖都是不会被加入到 classpath 中的,目前该bug尚未被修复。

     如果你做Spring Boot开发,有带provided的依赖时,直接在IDE中运行项目会导致ClassNotFound异常。

 https://youtrack.jetbrains.com/issue/IDEA-107048

 

解决方案一:

解决方案简单粗暴,找到pom.xml中的如下依赖

  1.  
    <dependency>
  2.  
    <groupId>org.springframework.boot</groupId>
  3.  
    <artifactId>spring-boot-starter-tomcat</artifactId>
  4.  
    <!--<scope>provided</scope>-->
  5.  
    </dependency>

将对应的scope 注释掉即可

 

解决方案二:

【推荐】在运行配置Configuration选项卡下Use classpath of module的下方有个复选框 Include dependences with "Provided" scope 把这个勾上就可以了。

解决方案三:

packaging为jar时,直接更改scopecompile(不推荐)

 

 

 

compile:

This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.

(未指定scope时默认使用该项。项目始终依赖使用该jar包。会传递依赖的项目)

 

provided:

This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.

(与compile类似,但表明你期望JDK或容器在运行时提供的依赖。例如,当构建一个Web应用程序的java企业版,你将依赖Servlet API和相关的java EE API提供的Web容器提供的范围,用于编译和测试阶段,不具有传递性。jar包不会包含依赖项)

 

runtime:

This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.

(表示被依赖项目不会参与项目的编译,但用于运行和测试。与compile相比,跳过了编译这个环节)

 

test:

This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases. This scope is not transitive.

(此范围表示应用程序的正常使用不需要依赖项,只适用于测试编译和执行阶段。不具有传递性。)

 

system:

This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.

(与provided相似,但必须我们给它提供显式JAR包。不会从maven远程中央仓库下载,而是从本地Maven仓库中获取。)

 

import (only available in Maven 2.0.9 or later):

This scope is only supported on a dependency of type pom in the section. It indicates the dependency to be replaced with the effective list of dependencies in the specified POM’s section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.

(import scope只能用在dependencyManagement里面。表示从其它的pom中导入dependency的配置。)

 

分享到:
评论

相关推荐

    Intellij IDEA 入门教程.pdf (高清文字版)

    IntelliJ IDEA是一款由JetBrains公司开发的Java集成开发环境(IDE),广泛应用于Java开发。本教程主要介绍IntelliJ IDEA的安装与配置、基本使用方法、常见问题解决技巧、以及与Maven、Git、Tomcat等工具的集成。 ...

    IntellijIdea开发工具详细使用文档.pdf

    IntelliJ Idea开发工具详细使用文档 IntelliJ IDEA是一款功能强大且灵活的集成开发环境(IDE),由 JetBrains 公司开发。它支持多种编程语言,包括 Java、Groovy、Kotlin、Scala 等。下面是 IntelliJ IDEA 的详细...

    IntelliJ IDEA 中文指南.pdf

    《IntelliJ IDEA 中文指南》是一份专注于介绍和指导用户使用IntelliJ IDEA集成开发环境(IDE)的文档,涵盖了从基础操作到高级特性的广泛知识点。IntelliJ IDEA是由JetBrains公司开发的一款现代化的Java集成开发环境...

    IntelliJ IDEA使用教程从入门到上瘾(2019图文版)

    IntelliJ IDEA 使用教程从入门到上瘾(2019 图文版) 本资源主要介绍了 IntelliJ IDEA 的使用教程,从基础到高级,涵盖了从设置工作空间到配置 Maven 等多个方面的知识点。 1. IDEA VS Eclipse 核心术语比较 在...

    IntelliJ IDEA 2019汉化文件.rar

    在2019年,IntelliJ IDEA发布了版本2019.1.3,这个版本在前一版的基础上进行了诸多改进和增强,旨在提升开发者的编程体验。 标题中的"IntelliJ IDEA 2019汉化文件.rar"指的是为解决中文用户语言障碍问题而提供的...

    Intellij IDEA教程

    IntelliJ IDEA是一款深受开发者喜爱的Java集成开发环境(IDE),尤其在Java Web开发领域有着广泛的应用。本教程将深入探讨IntelliJ IDEA的各项功能,帮助你从新手快速成长为熟练的使用者。 首先,IntelliJ IDEA的...

    IntelliJIDEA汉化包

    IntelliJ IDEA是一款广受欢迎的Java集成开发环境(IDE),由JetBrains公司开发。它以其高效、智能的代码补全、强大的调试工具和优秀的代码分析功能而闻名。汉化包是为了方便中国用户使用,将原本英文界面的IntelliJ ...

    intellij idea 中文语言包resources_zh_CN_IntelliJIDEA_2019.3_r1.jar

    IntelliJ IDEA是java编程语言开发的集成环境,不过官方是英文版的,这是一个汉化包,下载后放至IntelliJ IDEA安装目录的lib目录下就行,重新启动程序就是中文了。

    IntelliJ IDEA使用教程

    IntelliJ IDEA是一款由JetBrains公司开发的集成开发环境(IDE),专为Java语言设计,但也支持其他编程语言如Kotlin、Scala、Groovy等。它被广泛认为是目前最好的Java IDE之一。IntelliJ IDEA通过其智能代码助手、...

    史上最简单的 IntelliJ IDEA 教程

    史上最简单的 IntelliJ IDEA 教程

    Intellij Idea开发工具详细使用文档.pdf

    IntelliJ IDEA是一款由JetBrains公司开发的Java集成开发环境,以其高效、智能的代码补全、重构功能以及丰富的插件支持而广受开发者喜爱。本文档将详细讲解IntelliJ IDEA的使用方法,帮助开发者更好地掌握这款强大的...

    vscode-intellij-idea-keybindings, vs 代码的IntelliJ IDEA 键绑定端口.zip

    vscode-intellij-idea-keybindings, vs 代码的IntelliJ IDEA 键绑定端口 用于 Visual Studio 代码的 IntelliJ IDEA 键绑定 vs 代码的IntelliJ IDEA 键绑定端口。 包括 keymaps,WebStorm,PyCharm,PHP Storm等流行...

    IntelliJ IDEA 2020.1.4 x64官方

    IntelliJ IDEA是一款由JetBrains公司开发的集成开发环境(IDE),主要用于Java、Kotlin、Groovy、Scala等编程语言的开发工作。2020.1.4是该IDE的一个特定版本,针对x64架构,即64位操作系统。这个版本提供了许多功能...

    IntelliJ IDEA安装详解配置教程

    IntelliJ IDEA是一款深受开发者喜爱的Java集成开发环境(IDE),尤其在Java、Groovy、Scala等语言的开发中表现出色。本教程将详细介绍IntelliJ IDEA的安装过程及基本配置,帮助初学者快速上手。 一、安装步骤 1. ...

    IntelliJ IDEA 2017 汉化包

    "IntelliJ IDEA 2017 汉化包"主要是为了解决英文界面对于中文用户带来的阅读不便,尤其是对那些不熟悉英语或者英语水平有限的开发者。汉化包通常包含了软件所有界面元素的中文翻译,包括菜单、对话框、提示信息等,...

    resources_cn_IntelliJIDEA_2017.3-3.4.rar

    resources_cn_IntelliJIDEA_2017.3.1_r2.jar resources_cn_IntelliJIDEA_2017.3.2_r1.jar resources_cn_IntelliJIDEA_2017.3.3_r2.jar resources_cn_IntelliJIDEA_2017.3.4_r1.jar resources_...

    IntelliJ IDEA -settings.zip

    IntelliJ IDEA是一款广受欢迎的Java集成开发环境(IDE),由JetBrains公司开发。它以其高效、智能的代码补全、强大的调试工具和高度可定制的设置而闻名。本压缩包"IntelliJ IDEA -settings.zip"包含了用户的一些常用...

    intellij idea汉化包下载

    IntelliJ IDEA是一款备受开发者喜爱的Java集成开发环境(IDE),以其高效、智能的编码辅助和强大的项目管理功能而闻名。然而,对于中文用户来说,原生英文界面可能会造成一定的使用不便。在这种情况下,汉化补丁就...

Global site tag (gtag.js) - Google Analytics