java - 为什么我在 IntelliJ IDEA 中运行 spring boot 项目时没有将依赖项添加到类路径中?

标签 java spring maven spring-boot intellij-idea

我的操作系统是Ubuntu 16.04,IDE是IntellJ IDEA 2018.1.3。

最近我尝试在 Maven 中运行一个简单的 Spring Boot 项目,但是当我运行这个应用程序时,我收到一些错误消息,指出依赖项不存在,这如下: enter image description here

我猜依赖没有添加到classpath中,但是项目配置和maven依赖是正常的。我尝试在操作系统为 Windows 10 的其他计算机上运行同一个项目。它运行良好。

  • 专家:

enter image description here

  • 项目结构:

enter image description here

我的pom.xml

<?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>

<groupId>com.test</groupId>
<artifactId>test1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <junit.version>4.12</junit.version>
    <mysql.version>5.1.43</mysql.version>
</properties>


<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.8.RELEASE</version>
</parent>

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

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

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>1.3.1</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>${mysql.version}</version>
    </dependency>

    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>1.2.41</version>
    </dependency>
</dependencies>
</project>

最佳答案

我只是删除idea/bin/idea.properties文件中idea.system.path目录

删除.idea/*.iml文件,然后重新导入工程。

但是我仍然不知道这个问题的原因和解决方案。

关于java - 为什么我在 IntelliJ IDEA 中运行 spring boot 项目时没有将依赖项添加到类路径中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50394161/

相关文章:

java - SubscribeActivity : Null Pointer Exception error 中的 Edittext 异常

java - JDK 1.8 on unicode escape characters gives string literal is not properly closed by a double-quote 错误

java - 在 CanFly 接口(interface)中,必须使用 CanFly 类型的一个参数来声明 speed 方法

java - 跨 JVM 或 Application 实例或 Tomcat 实例的单例

javascript - Thymeleaf - 在 js 引号内包含 html 标签

java - Gradle 在 Central Maven 中因 pom.xml 格式错误而失败

spring - 使用 Hibernate L2 ehcache 和 spring bootenabledCache 时已经存在另一个未命名的 CacheManager

java - @Value 和 @Autowired 上的 NPE

java - 在java中更改javafx文件的路径

java - 如何获取多模块Maven项目中的项目基目录?