我的项目没有引用C:\ log4j-application.log的log4j配置文件,但maven有错误,因为它不存在。这是在Linux系统上。 “mvn package”命令出错:
Reactor Summary:
[INFO]
[INFO] a ............................................. SUCCESS [ 0.943 s]
[INFO] b ............................................. SUCCESS [ 8.659 s]
[INFO] c ............................................. SUCCESS [ 4.295 s]
[INFO] d ............................................. SUCCESS [ 2.867 s]
[INFO] e ............................................. FAILURE [ 0.093 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.071 s
[INFO] Finished at: 2016-12-16T17:53:42-06:00
[INFO] Final Memory: 48M/1029M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.4:jar (default-jar) on project web: Error assembling JAR: C:\log4j-application.log not found. -> [Help 1]
父pom.xml(模块e的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>
<groupId>foo</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>../b</module>
<module>../e</module>
<module>../d</module>
<module>../e</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<optimize>true</optimize>
<debug>true</debug>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>all-in-one</finalName>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<mainClass>Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>build-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
我的应用中的典型log4j.properties:
# Root logger option
log4j.rootLogger=DEBUG, stdout, file
# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
org.jooq.Constants.level=WARNING
~
是什么导致这个?到目前为止试图:
答案 0 :(得分:0)
好的,这绝对是我的疏忽。在导致问题的e / src / main / resources中有一个名为C:\ log4j-application.log的延迟文件。一旦它被删除,我跑了一个maven干净,一切都按预期工作。
我认为我开始使用的log4j配置文件设置为C:\ log4j-application.log然后我开始收到错误,因为它不存在。当时我在几个地方使用touch
创建了一个具有该名称的文件以绕过错误,但我从未删除所有这些错误。它是一个空文件,所以我的grep -R log4j-application .
命令从未找到它(我希望某个配置文件引用该文件)。捂脸。