我的操作系统是Ubuntu 16.04
,IDE是IntellJ IDEA
2018.1.3。
最近我尝试在 Maven
中运行一个简单的 Spring Boot
项目,但是当我运行这个应用程序时,我收到一些错误消息,指出依赖项不存在,这如下:
我猜依赖没有添加到classpath中,但是项目配置和maven依赖是正常的。我尝试在操作系统为 Windows 10
的其他计算机上运行同一个项目。它运行良好。
- 专家:
- 项目结构:
我的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/