我正在尝试构建一个以WAR项目为模块的Maven EAR项目。当我尝试向其添加log4j时,它无法找到位于Web项目的src / main / java文件夹中的log4j.properties文件。
它给出了以下错误 -
[6/12/15 12:43:26:786 IST] 0000009c SystemOut O log4j: Trying to find [log4j.properties] using ClassLoader.getSystemResource().
[6/12/15 12:43:26:786 IST] 0000009c SystemOut O log4j: Could not find resource: [null].
以下是我在web项目中的pom.xml文件
<?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>
<artifactId>HR-PrepLoad-ui</artifactId>
<packaging>war</packaging>
<name>${project.artifactId}</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.hemant.css.hr</groupId>
<artifactId>HR-PrepLoad</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.hemant.css.hr</groupId>
<artifactId>HR-PrepLoad-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
<parent>
<groupId>com.hemant.css.hr</groupId>
<artifactId>HR-PrepLoad</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
</project>
是否有人对可能导致此问题的原因有任何建议?
答案 0 :(得分:1)
您的log4j.properties
文件应位于资源文件夹中。
尝试将其从src/main/java
放到资源文件夹