gpt4 book ai didi

java - 发布时找不到资源包

转载 作者:太空宇宙 更新时间:2023-11-04 10:25:57 24 4
gpt4 key购买 nike

我有一个多模块 Maven 项目,如下所示:

reactor
| core
| console
| custom-maven-plugin (depends on core)
| test-deployment

我有一个基本名称为 login 的资源包,我将其从 Git 中排除,因为它包含密码。在我的项目中,该文件位于 core/src/test/resources 中,我有一个测试类,它的使用方式如下:

public abstract class TestBase {
private static final ResourceBundle constants = ResourceBundle.getBundle("constants");
private static final ResourceBundle bundle = ResourceBundle.getBundle("login");
private Connection connection;

// ...

Connection getConnection() {
// Connection will be created in another method, this one just returns it.
}
}

public class ActualTest extends TestBase {
// Uses the connection in tests here.
}

现在,如果我对整个项目执行 mvn package,测试都会正确完成。

在我的构建服务器上,我有一个用于创建 login.properties 的脚本,因为它不包含在克隆的项目中:

printf "userName=$bamboo_login_userName\npassword=$bamboo_login_password" > core/src/test/resources/login.properties

构建服务器执行了mvn clean release:prepare release:perform,但是此时构建失败,出现以下异常:

java.util.MissingResourceException: Can't find bundle for base name login, locale en_US

我已经检查了目录core/src/test/resourcescore/target/test-classes,但文件就在那里。由于某种原因,常量 的资源包不会抛出异常,这告诉我,我创建该登录文件的方式存在问题。

对于这种行为有什么解释吗?

最佳答案

您不应该在main而不是test中生成login.properties吗?

printf "userName=$bamboo_login_userName\npassword=$bamboo_login_password" > core/src/main/resources/login.properties

关于java - 发布时找不到资源包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50530000/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com