首页 > 代码库 > maven:log4j:WARN No appenders could be found for logger (loggerInfo).或者maven build error:org.apache.maven.lifecycle.LifecycleExecutionExceptio
maven:log4j:WARN No appenders could be found for logger (loggerInfo).或者maven build error:org.apache.maven.lifecycle.LifecycleExecutionExceptio
maven在build构建时,加载资源文件时需要配置资源文件插件:
1,在pom.xml文件中加入
<build>
<finalName>${project.build.target.file.name}</finalName>
<directory>${basedir}/target</directory>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<outputDirectory>${basedir}/target/classes</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
2,project-->clean项目
3,重新运行,OK!
不添加插件,将在main方法里会无法正常初始化log4j,产生异常:
maven:log4j:WARN No appenders could be found for logger (loggerInfo).
maven build error for project;Build errors for zlsoft-web; org.apache.maven.lifecycle.LifecycleExecutionException
maven:log4j:WARN No appenders could be found for logger (loggerInfo).或者maven build error:org.apache.maven.lifecycle.LifecycleExecutionExceptio