春季启动失败,执行目标org.apache.maven.plugins:Maven的万无一失,插件:

2019-11-05 08:27发布

我使用的Eclipse版本:2018-09(4.9.0)和我已经安装了Eclipse中的弹簧工具套装(STS)为构建春季启动应用程序。

- >当过我创造新的春天启动项目,并尝试Maven构建我的项目没有任何代码的补充。 构建失败,下面的错误。

[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project DemoSpringProject: There are test failures.
[ERROR] 
[ERROR] Please refer to C:\Users\SP064774\Util-Workspace\DemoSpringProject\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

如果我删除其为具有默认测试的测试文件夹。 它做工精细。 但是,为什么会这样。 文件夹下面是一个我删除它通过弹簧启动项目产生

src/test/java

提前致谢。

更新

下面是一个得到生成的默认测试文件。

@RunWith(SpringRunner.class)
@SpringBootTest
public class DemoSpringProjectApplicationTests {

  @Test
  public void contextLoads() {
  }

}

从refered文件日志。 C:\用户\ SP064774 \的Util-工作区\ DemoSpringProject \目标\万无一失的报告

--------------------------------------------------------------------
Test set: com.example.demo.DemoSpringProjectApplicationTests
-------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.473 s 

FAILURE! - in com.example.demo.DemoSpringProjectApplicationTests
contextLoads(com.example.demo.DemoSpringProjectApplicationTests)  Time 
elapsed: 0.002 s  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: 
org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 

“org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration”:通过构造符参数0表示不合格依赖; 嵌套的例外是org.springframework.beans.factory.BeanCreationException:错误创建名为“数据源”豆在类路径资源定义[组织/ springframework的的/ boot /自动配置/ JDBC / DataSourceConfiguration $阿光的.class]:豆通过工厂方法实例失败; 嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例[com.zaxxer.hikari.HikariDataSource]:出厂方法“的dataSource”扔除外; 嵌套的例外是org.springframework.boot.autoconfigure.jdbc.DataSourceProperties $ DataSourceBeanCreationException:无法确定所致合适的驱动程序类:org.springframework.beans.factory.BeanCreationException:错误创建名为“数据源”豆在类路径资源定义[组织/ springframework的的/ boot /自动配置/ JDBC / DataSourceConfiguration $ Hikari.class]:通过工厂方法实例化Bean的失败; 嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例[com.zaxxer.hikari.HikariDataSource]:出厂方法“的dataSource”扔除外; 嵌套的异常是org.springframework.boot.autoconfigure.jdbc.DataSourceProperties $ DataSourceBeanCreationException:无法确定致合适的驱动程序类:org.springframework.beans.BeanInstantiationException:无法实例[com.zaxxer.hikari.HikariDataSource]:出厂方法“数据源”扔除外; 嵌套的例外是org.springframework.boot.autoconfigure.jdbc.DataSourceProperties $ DataSourceBeanCreationException:无法确定所致合适的驱动程序类:org.springframework.boot.autoconfigure.jdbc.DataSourceProperties $ DataSourceBeanCreationException:无法确定合适的驱动程序类

的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>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.1.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>DemoSpringProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>DemoSpringProject</name>
<description>Demo project for Spring Boot</description>

<properties>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-integration</artifactId>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Answer 1:

您还没有共享您的pom.xml文件,所以我不能肯定,但它看起来像你没有classpath中的数据库驱动程序。 你要么需要添加一个嵌入式数据库(H2或HSQLDB)或设置了一个单独的数据库如MySQL或者Postgres的的依赖关系,并添加相应的驱动程序作为一个依赖。



Answer 2:

在Eclipse中转到Windows的>首选项> Java的>安装JRE和变化路径JDK主文件夹



Answer 3:

更新Jar插件到3.1.1立即解决了这个问题:

<properties>
  <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>

https://github.com/spring-projects/spring-boot/issues/16846#issuecomment-492792506



文章来源: Spring Boot Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test