MyEclipse Import Maven Project Pom file The first line error, run Tomcat report log4j errors--workaround

Source: Internet
Author: User
Tags log4j

Problem Description:

A period of time before the first computer to import Maven project, but also pom file wrong, and then run the Tomcat report log4j error, has been daoteng nearly one months to run the program successfully, too difficult.

Also on the internet for a long time, there is no way to solve my problem. Write down the solution, hoping to help the web just like me to get started.

(Just getting started, there must be a wrong place to say, mistakes also want to point out, I correct)

Pre-operation: After importing the project Clean,install,update, the error (because I have solved, so there is no x).

Two problems correspond to the workaround:

The first line of the 1.pom file is a big red fork, which indicates that the project's file points to an incorrect path, such as the error. /webapp/. The wrong not to see, these are the framework of the fault, and the framework is not wrong, so do not tube, remove these errors, look at the wrong address of the project itself, and find the wrong files, delete them (do not worry, these will be automatically generated in the post-update, and these automatically generated is the correct), Remove the frame of the wrong file after all deleted, then update, and then delete, repeat the above steps several times, POM will not error, successful solution ~!

2. Start Tomcat, can't run, always have this

And then stuck, translation is log4j not initialized meaning, surf the internet to check the error message, said there is no log4j configuration file, (premise: There is log4j package, if there is no log4j package, it may be missing the reason for the package, Internet download and add can), Therefore, you need to create a new file in conf similar to the following directory named Log4j.properties

and add content to it

Log4j.rootlogger=debug, stdout
Log4j.appender.stdout=org.apache.log4j.consoleappender
Log4j.appender.stdout.layout=org.apache.log4j.patternlayout
Log4j.appender.stdout.layout.conversionpattern=%-d{yyyy-mm-dd HH\:MM\:SS} [%c]-[%p]%m%n
Log4j.appender.stdout.Target = System.out

# # # Output to the log file # # # #
LOG4J.APPENDER.D = Org.apache.log4j.DailyRollingFileAppender
Log4j.appender.d.file = ${scores.root}/web-inf/logs/error.log
Log4j.appender.d.append = True
Log4j.appender.d.threshold = ERROR
Log4j.appender.d.layout = Org.apache.log4j.PatternLayout
Log4j.appender.d.layout.conversionpattern =%-d{yyyy-mm-dd HH:mm:ss} [%t:%r]-[%p]%m%n
Log4j.appender.ServerDail yrollingfile=org.apache.log4j.dailyrollingfileappender 
Log4j.appender.serverdailyrollingfile.datepattern= '. ' yyyy-mm-dd 
Log4j.appender.serverdailyrollingfile.file=${scores.root}/web-inf/logs/error.log
log4j.appender.serverdailyrollingfile.layout=org.apache.log4j.patternlayout 
log4j.appender.serverdailyrollingfile.layout.conversionpattern=%-d{yyyy-mm-dd HH\:mm\:ss} [%t\:%r]-[%p]%m%n  
Log4j.appender.serverdailyrollingfile.append=true

Log4j.logger.com.ibatis=debug
Log4j.logger.com.ibatis.common.jdbc.simpledatasource=debug
Log4j.logger.com.ibatis.common.jdbc.scriptrunner=debug
Log4j.logger.com.ibatis.sqlmap.engine.impl.sqlmapclientdelegate=debug
Log4j.logger.org.mybatis=debug
Log4j.logger.java.sql.connection=debug
Log4j.logger.java.sql.statement=debug
Log4j.logger.java.sql.preparedstatement=debug,stdout
Com.ng.mapper=debug

After creation, find the Web. XML in a directory similar to the following

Find out if the following statement is available

<context-param> 
     <param-name>log4jConfigLocation</param-name>  
     <param-value>classpath:conf/log4j.properties</param-value> 
</context-param> 

<context-param> 
     <param-name> log4jrefreshinterval</param-name> 
     <param-value>60000</param-value > 
</context-param> 
<listener> 
     <listener-class >&NBSP
          org.springframework.web.util.log4jconfiglistener 
     </listener-class> 
</listener> 

<listener> 
    &NBSP;<LISTENER-CLASS>&NBSP,
          org.springframework.web.context.contextloaderlistener 
     </listener-class> 
</listener>

If there is, first check whether the statement is complete, the monitoring and declaration order can not be reversed, otherwise it will error; second, look at the code where the address is not wrong, the address must have just added the address of the Log4j.properties configuration file, otherwise it will be reported not Found Log4j.properties's error.

If you do not have the code, add the above code to Web. XML, save, update, start Tomcat, and finally run successfully!!

MyEclipse Import Maven Project Pom file The first line error, run Tomcat report log4j errors--workaround

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.