【问题标题】:Getting errors while building Maven project in Netbeans?在 Netbeans 中构建 Maven 项目时出错?
【发布时间】:2015-09-12 15:08:31
【问题描述】:

我在尝试在 Netbeans 中构建 Java EE(Maven) 项目时遇到这些错误(在使用 mvn clean install -U 从 cmd 构建时也遇到相同的错误)

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project myproject: There are test failures.

奇怪的是,我在另一台 PC 上尝试时遇到了同样的错误,但是,当我在学校尝试构建时,没有错误,而且运行良好。学校的测试错误为零。

为什么会这样?有人有什么主意吗?

很抱歉,如果这个问题是一个“糟糕”的 stackoverflow 问题,但我无处可去寻求帮助。

编辑:

现在我得到了这个:

Tests run: 10, Failures: 0, Errors: 0, Skipped: 0

这很好,但我仍然收到此错误并构建失败:

Failed to execute goal org.apache.maven.plugins:maven-source-plugin:2.4:jar (attach-sources) on project backend: Execution attach-sources of goal org.apache.maven.plugins:maven-source-plugin:2.4:jar failed: Plugin org.apache.maven.plugins:maven-source-plugin:2.4 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-source-plugin:jar:2.4 (): Failed to read artifact descriptor for org.apache.maven:maven-archiver:jar:2.5: Could not transfer artifact org.apache.maven:maven-archiver:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.maven.apache.org -> [Help 1]

在构建开始时,我收到以下警告:

Some problems were encountered while building the effective model for edu.cth.myproject:backend:ejb:1.0-SNAPSHOT

build.plugins.plugin.version for org.apache.maven.plugins:maven-source-plugin is missing. build.plugins.plugin.version for org.apache.maven.plugins:maven-javadoc-plugin is missing. build.plugins.plugin.version for org.apache.maven.plugins:maven-deploy-plugin is missing. It is highly recommended to fix these problems because they threaten the stability of your build. For this reason, future Maven versions might no longer support building such malformed projects.

我不知道该怎么办?

【问题讨论】:

  • 测试在某些平台上可能会因多种原因而在其他平台上失败。我建议您将问题简化为一个失败的测试并在此处发布。
  • @Tunaki 这是第一行错误:Local Exception Stack: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.
  • 添加-X选项,仔细查看输出控制台。
  • @lametaweb 会试试看的!
  • “在端口 1527 上连接到服务器 localhost 时出错”不言自明。您有一个尝试连接到 localhost 服务器的测试,但它失败了。该服务器是否正确启动并运行?它是否正确接受来自端口 1527 的输入?这个端口开放了吗?

标签: java apache maven jakarta-ee netbeans


【解决方案1】:

您有测试失败。这意味着明确设计用于测试事情是否正常的代码,现在说它没有。

调查测试报告以找出故障所在 - 这在 Netbeans 中可能是最简单的(告诉它运行测试)。这可能是任何事情。我的猜测可能是测试尝试与您在家中无法访问的学校网络上的服务器通信,但您需要进行调查才能确定。


编辑:在 cmets 中发布的错误消息表明,代码期望数据库服务器在端口 1527 上运行,但没有。

显然这是 Derby 数据库(在 JDK 的精简版中可用),您需要手动调用服务器。您可能从老师那里收到了有关如何正确设置的信息。

这个 youtube 视频声称说“如何修复 netbeans 数据库端口 1527 错误”。 https://www.youtube.com/watch?v=DM7g0hm_s4w

【讨论】:

  • 我也是这么认为的,好像是jdbc错误。这是第一行错误:Local Exception Stack: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect
  • 如果我用 VPN 连接到学校网络,它会起作用吗?对不起,如果是愚蠢的问题,但我是新手。
  • 你能贴出究竟是什么错误吗?可能是您的系统上没有安装 DBMS 服务器。
  • @Imran 和 Thorbjörn 请检查我对帖子所做的编辑
  • 刚刚看到您对帖子的编辑。我确实手动调用了服务器,但我现在有不同的错误,我现在包含在我上面的帖子中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-19
  • 1970-01-01
  • 2013-06-24
  • 2011-11-04
  • 2019-01-27
  • 1970-01-01
相关资源
最近更新 更多