Maven 's assembly plugin uses:
Recently doing a small project, using Java to start running.
assembly will need to use the jar Span style= "font-family: ' The song Body '; > are packaged into a
When you specify mainClasson the configuration, you canrun the main function of java without specifying the containing main The classpath name of the function. It is very easy to run the following jar file (running in the background):nohup java-jar Calculatescore.jar &
The first step: you need to add the configuration in the XML of the Pom ;
Step Two: Configure maven Run configurations,goals configured as assembly:assembly can be.
The above process has been in use, very normal. But there are problems with recent small applications:
Out of the jar package does not produce a log file, in particular, does not generate log4j log information, the program runs normally without error, no hint.
Online various queries, no results. In order to solve the problem, various attempts.
There is always a question in my mind: the previous normal use, can print the log, why this is not?
All sorts of attempts are not possible, so we'll look at the anti-compilation jar package. The results found that the log4j.properties file is not their own file, do not know which package, and their programs are used in the Logger. GetLogger (name) , so the log information cannot be printed.
Here's the question, why not your own log4j profile?
When Maven is packaged , there are log messages in the Console , a closer look at the discovery, multiple hints that log4j 's configuration has been added and skipped.
So guess: must be packaged in the process, the first load of the other jar log4j configuration files, and later include their own application of the log4j The configuration files are ignored.
But the problem comes again, I used the same way before, also used a lot of third-party packages, all contain log4j configuration files, why are there no problems? See the previous taxi pack,log4j configuration files are configured in their own projects, this is why?
So we started to compare the package configuration process for differences and new discoveries:
The Maven packaged Run configurations configuration has the item Base directory, where there is a problem with the configuration.
As shown in the following two images:
If the project selected through Browse Workspace is configured in Base directory , the above problem will be generated;
If the file address path selected through the Browse file System is configured in Base directory , the above problem does not occur.
The specific reasons for this situation, need to be studied.
How the problem will be configured:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/90/wKioL1Xmz3jiXp7mAASkeQR_2aI145.jpg "title=" Picture 1.png "alt=" Wkiol1xmz3jixp7maaskeqr_2ai145.jpg "/>
does not cause problems to be configured :
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/93/wKiom1XmzXeAqrcgAASqDnDPmgQ009.jpg "title=" Picture 2.png "alt=" Wkiom1xmzxeaqrcgaasqdndpmgq009.jpg "/>
Maven assembly package file is overwritten.