【发布时间】:2018-10-27 21:10:29
【问题描述】:
我的操作系统是Ubuntu 16.04,IDE是IntellJ IDEA 2018.1.3.
最近我尝试在Maven中运行一个简单的Spring Boot项目,但是当我运行这个应用程序时,我收到一些依赖项不存在的错误消息,如下所示:
我猜依赖没有添加到类路径,但是项目配置和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>
【问题讨论】:
-
您是否使用
Spring Initializr创建了项目?当您创建一个 Maven 项目并添加所有spring依赖项时,就会发生这种情况。我也在使用 Ubuntu 16.04 -
@SAM 不,我先创建一个空项目,然后在项目结构中添加新的 maven 模块。
-
这就是你面临这个问题的原因。但你也可以继续,让我给你发一张屏幕截图。
-
@SAM 我用的是Spring Initializr,但还是报错。
-
查看我的更新...
标签: java spring maven spring-boot intellij-idea