无法从其他模块找到资源进行maven构建

问题描述 投票:0回答:1

需要专家的帮助。我使用 ant 多年,然后在我的项目中改用 gradle,所以我从来没有真正搞乱过 Maven。在 Maven 项目中,总有一个专家来处理它。

所以现在我开始了一份新工作,并负责一个多年未建的旧项目。在 subversion 中找到了源代码并检查了它并安装了 maven 并正在构建。

该项目由多个带有父 pom 的模块组成。这是我添加 junit-vintage 来运行测试的父 pom 文件。

<?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>
    
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties> 
        
  <groupId>com.gs.juror.kiosk.services</groupId>
  <artifactId>KioskServices</artifactId>
  <version>2.0</version>
  <packaging>pom</packaging>

  <name>KioskServices</name>
  <url>http://maven.apache.org</url>

  <scm>
    <developerConnection>scm:svn:svn://cceballo:[email protected]/fedKioskWebservice/trunk/KioskServices/</developerConnection>
  </scm>

  


<repositories>
<!-- 
    <repository>
         <name>repo</name>
         <url>http://lexsvn1test:8081/artifactory/repo</url>
         <id>repo</id>
    </repository>
     -->
    <repository>
        <id>com.springsource.repository.bundles.release</id>
        <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
        <url>http://repository.springsource.com/maven/bundles/release</url>
    </repository>

    <repository>
        <id>com.springsource.repository.bundles.external</id>
        <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
        <url>http://repository.springsource.com/maven/bundles/external</url>
    </repository>

    <repository>
        <id>central</id>
        <url>https://repo1.maven.org/maven2</url>
        <releases>
            <enabled>true</enabled>
        </releases>
    </repository>
</repositories>

<dependencyManagement>
    <dependencies>
   <!-- Junit dependencies -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>5.11.3</version>
        <scope>test</scope>
    </dependency>
     <!-- End of Junit dependencies -->
     <!-- logging -->
    <dependency>
        <groupId>org.lucee</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.20.0</version>
    </dependency>
    <dependency>
        <groupId>org.lucee</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.20.0</version>
    </dependency>
    <!-- End of logging -->
     <!-- Spring dependencies -->
   <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
    </dependency>
  <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.0.6.RELEASE</version>
    </dependency>
     <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.0.6.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-websocket</artifactId>
    <version>4.0.6.RELEASE</version>
    </dependency>      
    <!-- End of spring dependencies -->
    <dependency>
        <groupId>net.sf.oval</groupId>
        <artifactId>oval</artifactId>
        <version>1.84</version>
    </dependency>
    
    
    <dependency>
        <groupId>com.gs.juror.kiosk.services</groupId>
        <artifactId>Crypto</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gs.juror.kiosk.services</groupId>
        <artifactId>Commons</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gs.juror.kiosk.services</groupId>
        <artifactId>ConfigurationEngine</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gs.juror.kiosk.services</groupId>
        <artifactId>Core</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gs.juror.kiosk.services</groupId>
        <artifactId>WebREST</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gs.juror.kiosk.services</groupId>
        <artifactId>Security</artifactId>
        <version>${project.version}</version>
    </dependency>
    
    
    
  </dependencies>
</dependencyManagement>  
  
  
<dependencies>
   <!-- Junit dependencies -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>
     <!-- End of Junit dependencies -->
     <!-- logging -->
    <dependency>
        <groupId>org.lucee</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.20.0</version>
    </dependency>
    <dependency>
        <groupId>org.lucee</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.20.0</version>
    </dependency>
    <!-- End of logging -->
    
     <!-- Spring dependencies -->
   <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        </dependency>
  <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        </dependency>
     <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-websocket</artifactId>
    </dependency>
    <!-- End of spring dependencies -->
    <dependency>
        <groupId>net.sf.oval</groupId>
        <artifactId>oval</artifactId>
    </dependency>
</dependencies>  
  
  
  <modules>
    <module>Crypto</module>
    <module>Commons</module>
    <module>ConfigurationEngine</module>
    <module>Core</module>
    <module>WebREST</module>
    <module>Security</module>
  </modules>
  
  
  
  <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
        </plugin>
    </plugins>
  </build>
</project>

而且我知道 Maven 项目应该可以工作,所以我运行了

mvn deploy
但它失败了,因为未指定部署。所以我运行 mvn package 来构建我需要发送给客户端的文件,但失败了。

总结如下:

[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   AppTest.testConfigurationLoader_getWorkflowconfigurationByCourtLocation:33 » MissingResource Can't find bundle for base name StartupConfiguration, locale en_US
[ERROR]   AppTest.testConfigurationLoader_loadconfiguration:27 » MissingResource Can't find bundle for base name StartupConfiguration, locale en_US
[ERROR]   AppTest.testConfigurationLoader_write:21 » MissingResource Can't find bundle for base name StartupConfiguration, locale en_US
[INFO] 
[ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for KioskServices 2.0:
[INFO] 
[INFO] KioskServices ...................................... SUCCESS [  0.009 s]
[INFO] Crypto ............................................. SUCCESS [ 13.360 s]
[INFO] Commons ............................................ SUCCESS [  5.168 s]
[INFO] ConfigurationEngine ................................ FAILURE [  6.527 s]
[INFO] Security ........................................... SKIPPED
[INFO] Core ............................................... SKIPPED
[INFO] WebREST ............................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  25.727 s
[INFO] Finished at: 2024-11-12T07:29:31-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.2.5:test (default-test) on project ConfigurationEngine: 

它在测试 AppTest 中失败。这是测试代码:

public class AppTest {
  
  private static Logger logger = LogManager.getLogger();
  
    @Test
    public void testConfigurationLoader_write(){
        ConfigurationLoader configurationLoader = new XMLConfigurationLoader();  //fails here
        configurationLoader.writeGlobalConfigurationSample();
    }

测试失败的代码是:

public XMLConfigurationLoader() {
    
    xStream = new XStream(new StaxDriver());
    
    startUpBundle = ResourceBundle.getBundle("StartupConfiguration"); //fails here

于是我使用IntelliJ的find查找StartupConfiguration,找到了两份StartupConfiguration.properties。两者都在 WebREST 项目中,一个在

src/main/resources
,另一个在
src/main/prod

所以现在,我的问题是,我该如何处理这个问题?我总是可以制作文件的另一个副本,但想看看是否有更好的方法来解决这个问题。

java maven resources
1个回答
0
投票

为了解决这个问题,我最终只是将该项目添加到我的测试资源中。希望这对其他人有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.