【问题标题】:Properties file not added while trying to compile 'jar-with-dependencies' in Maven尝试在 Maven 中编译“jar-with-dependencies”时未添加属性文件
【发布时间】:2013-07-04 12:03:31
【问题描述】:

我正在尝试使用 Maven 程序集插件生成 jar 文件。除了我的 log4j.properties 文件外,一切都是正确的;当我运行 jar 文件时,控制台输出:

log4j:WARN 找不到记录器的附加程序 (com.xxxxxxxxx.web.processengine.Main)。 log4j:WARN 请初始化 log4j 系统正确。 log4j:WARN 见 http://logging.apache.org/log4j/1.2/faq.html#noconfig 了解更多信息。

在 Eclipse 中运行良好;所以我认为是某种类型的编译问题;这是我的程序集插件 pom 配置:

<plugin>
        <artifactId>maven-assembly-plugin</artifactId>

        <configuration>
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>  
            <archive>
                <manifest>
                    <mainClass>com.xxxxxxxxx.web.processengine.Main</mainClass>
                </manifest>
            </archive>
        </configuration>

        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
            </execution>
      </executions>
    </plugin>

感谢任何帮助,谢谢。

【问题讨论】:

  • log4j.properties 是否包含在工件中?
  • 尝试将 log4j.properties 文件放在 src/main/resources 文件夹中
  • @Anders R. Bystrup,我不明白这个问题,这个包含文件的工件到底在哪里?
  • @BGR,你是对的,我的文件在 src/main/resources/META-INF 下,而不是直接在 src/main/resources 下。现在有效。
  • 我会把它作为一个答案,以便您可以关闭问题

标签: java maven jar


【解决方案1】:

尝试将 log4j.properties 文件放在 src/main/resources 文件夹中

【讨论】:

    猜你喜欢
    • 2012-01-31
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 2011-07-13
    • 1970-01-01
    • 1970-01-01
    • 2014-07-22
    • 1970-01-01
    相关资源
    最近更新 更多