jjzjj

java - application.xml 不存在。 maven EAR 构建期间出错

coder 2024-06-27 原文

我正在尝试构建一个包含两个 war 文件的 ear 项目。构建 EAR 时出现“application.xml 不存在”错误。但我已将 application.xml 放在项目 META INF 文件夹中。请在下面找到代码。并提出解决方案。

下面是我的POM.XML

<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>au.com.mercury</groupId>
  <artifactId>ReplenishmentR4</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>ear</packaging>
  <build>
  <plugins>
    <plugin>
      <artifactId>maven-ear-plugin</artifactId>
      <version>2.6</version>
      <configuration>
        <applicationXML>src/main/application/META-INF/application.xml</applicationXML>
        <generateApplicationXml>false</generateApplicationXml>
        <encoding>UTF-8</encoding>
        <defaultLibBundleDir>lib/</defaultLibBundleDir>
        <filtering>true</filtering>
        <modules>
          <webModule>
            <groupId>au.com.mercury</groupId>
            <artifactId>Replenishment</artifactId>
            <bundleFileName>Replenishment.war</bundleFileName>
          </webModule>
          <webModule>
            <groupId>au.com.mercury</groupId>
            <artifactId>ReplenishmentR3</artifactId>
            <bundleFileName>ReplenishmentR3.war</bundleFileName>
          </webModule>
        </modules>
      </configuration>
    </plugin>
    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
  </plugins>
   <finalName>ReplenishmentR4</finalName>
</build>

<dependencies>

  <dependency>
    <groupId>au.com.mercury</groupId>
    <artifactId>Replenishment</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <type>war</type>
  </dependency>
  <dependency>
    <groupId>au.com.mercury</groupId>
    <artifactId>ReplenishmentR3</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <type>war</type>
  </dependency>
  </dependencies>
</project>

下面是我的application.xml

<?xml version="1.0" encoding="UTF-8"?>
<application>
  <module>
    <web>
      <web-uri>Replenishment.war</web-uri>
      <context-root>/Replenishment</context-root>
    </web>
  </module>
  <module>
    <web>
      <web-uri>ReplenishmentR3.war</web-uri>
      <context-root>/ReplenishmentR2</context-root>
    </web>
  </module>
</application>

为项目结构打开此图像。

Project structure

Maven 构建控制台错误:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building ReplenishmentR4 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for au.com.woolworths.mercury:ReplenishmentR3:war:0.0.1-SNAPSHOT is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ ReplenishmentR4 ---
[INFO] Deleting C:\Users\xagh9\workspace\ReplenishmentR4\target
[INFO] 
[INFO] --- maven-ear-plugin:2.6:generate-application-xml (default-generate-application-xml) @ ReplenishmentR4 ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ReplenishmentR4 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\xagh9\workspace\ReplenishmentR4\src\main\resources
[INFO] 
[INFO] --- maven-ear-plugin:2.6:ear (default-ear) @ ReplenishmentR4 ---
[INFO] Copying artifact[war:au.com.mercury:Replenishment:0.0.1-SNAPSHOT] to[Replenishment.war]
[INFO] Copying artifact[war:au.com.mercury:ReplenishmentR3:0.0.1-SNAPSHOT] to[ReplenishmentR3.war]
[INFO] Copy ear sources to C:\Users\xagh9\workspace\ReplenishmentR4\target\ReplenishmentR4
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.177 s
[INFO] Finished at: 2016-12-24T22:33:03+11:00
[INFO] Final Memory: 12M/164M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.6:ear (default-ear) on project ReplenishmentR4: Deployment descriptor: C:\Users\xagh9\workspace\ReplenishmentR4\target\ReplenishmentR4\META-INF\application.xml does not exist. -> [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/MojoExecutionException

最佳答案

1) application.xml自 JavaEE 5.0 以来,不再需要 EAR 中的文件

2) 在 maven-ear-plugin 配置中,您不生成 application.xml文件:

 <generateApplicationXml>false</generateApplicationXml>

并且您指定了 application.xml 的位置这里:<applicationXML>src/main/application/META-INF/application.xml</applicationXML>

因此,您应该确定 application.xml文件位于此位置:src/main/application/META-INF

3)最简单的就是不用<generateApplicationXml>false</generateApplicationXml> .它避免你声明 application.xml文件。

关于java - application.xml 不存在。 maven EAR 构建期间出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41312948/

有关java - application.xml 不存在。 maven EAR 构建期间出错的更多相关文章

  1. ruby-on-rails - 如何从 format.xml 中删除 <hash></hash> - 2

    我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为

  2. ruby-on-rails - Rails 应用程序中的 Rails : How are you using application_controller. rb 是新手吗? - 2

    刚入门rails,开始慢慢理解。有人可以解释或给我一些关于在application_controller中编码的好处或时间和原因的想法吗?有哪些用例。您如何为Rails应用程序使用应用程序Controller?我不想在那里放太多代码,因为据我了解,每个请求都会调用此Controller。这是真的? 最佳答案 ApplicationController实际上是您应用程序中的每个其他Controller都将从中继承的类(尽管这不是强制性的)。我同意不要用太多代码弄乱它并保持干净整洁的态度,尽管在某些情况下ApplicationContr

  3. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  4. java - 等价于 Java 中的 Ruby Hash - 2

    我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/

  5. java - 从 JRuby 调用 Java 类的问题 - 2

    我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www

  6. java - 我的模型类或其他类中应该有逻辑吗 - 2

    我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我

  7. ruby-on-rails - rspec - 如何检查方法是否存在? - 2

    我的模型有defself.empty_building//stuffend我怎样才能对这个现有的进行rspec?,已经尝试过:describe"empty_building"dosubject{Building.new}it{shouldrespond_to:empty_building}endbutgetting:Failure/Error:it{shouldrespond_to:empty_building}expected#torespondto:empty_building 最佳答案 你有一个类方法self.empty_bu

  8. java - 什么相当于 ruby​​ 的 rack 或 python 的 Java wsgi? - 2

    什么是ruby​​的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht

  9. ruby - 在 Ruby 中构建长字符串的简洁方法 - 2

    在编写Ruby(客户端脚本)时,我看到了三种构建更长字符串的方法,包括行尾,所有这些对我来说“闻起来”有点难看。有没有更干净、更好的方法?变量递增。ifrender_quote?quote="NowthatthereistheTec-9,acrappyspraygunfromSouthMiami."quote+="ThisgunisadvertisedasthemostpopularguninAmericancrime.Doyoubelievethatshit?"quote+="Itactuallysaysthatinthelittlebookthatcomeswithit:themo

  10. Observability:从零开始创建 Java 微服务并监控它 (二) - 2

    这篇文章是继上一篇文章“Observability:从零开始创建Java微服务并监控它(一)”的续篇。在上一篇文章中,我们讲述了如何创建一个Javaweb应用,并使用Filebeat来收集应用所生成的日志。在今天的文章中,我来详述如何收集应用的指标,使用APM来监控应用并监督web服务的在线情况。源码可以在地址 https://github.com/liu-xiao-guo/java_observability 进行下载。摄入指标指标被视为可以随时更改的时间点值。当前请求的数量可以改变任何毫秒。你可能有1000个请求的峰值,然后一切都回到一个请求。这也意味着这些指标可能不准确,你还想提取最小/

随机推荐