ログモードlog 4 j
1、新しいmavenプロジェクト:mvn archetype:create-DgroupId=org.sonatype.mavenbook.ch04 -DartifactId=simple-weather -DpackageName=org.sonatype.mavenbook 2、javaファイルの作成:Main.JAva:キーコード
Weather.javaWeatherFormatter.javaYahooParser.javaYahooRetriever.JAva 3、リソースファイルの作成:log 4 j.propertiesoutput.vm 4、構築プロジェクト:mvn install 5、実行プログラム:mvn exec:java-Depec.mainClass=org.sonatype.mavenbook.weather.Main表示結果:[INFO]Scanning for projects...[INFO][INFO] ------------------------------------------------------------------------[INFO] Building simple-weather 1.0[INFO] ------------------------------------------------------------------------[INFO][INFO] --- exec-maven-plugin:1.3.1:java (default-cli) @ simple-weather ---[WARNING] Warning: killAfter is now deprecated. Do you need it ? Please comment on MEXEC-6.0 INFO YahooRetriever - Retrieving Weather Data411 INFO YahooParser - Creating XML Reader518 INFO YahooParser - Parsing XML Response559 INFO WeatherFormatter - Formatting Weather Data642 INFO mavenbook - ********************************* Current Weather Conditions for: Evanston, IL, US Temperature: 72 Condition: Partly Cloudy Humidity: 87 Wind Chill: 72*********************************[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 1.831s[INFO] Finished at: Wed Jun 25 10:21:45 CST 2014[INFO] Final Memory: 9M/23M[INFO] ------------------------------------------------------------------------
// Configure Log4J log4j ,
PropertyConfigurator.configure(Main.class.getClassLoader().getResource("log4j.properties");
Weather.javaWeatherFormatter.javaYahooParser.javaYahooRetriever.JAva 3、リソースファイルの作成:log 4 j.propertiesoutput.vm 4、構築プロジェクト:mvn install 5、実行プログラム:mvn exec:java-Depec.mainClass=org.sonatype.mavenbook.weather.Main表示結果:[INFO]Scanning for projects...[INFO][INFO] ------------------------------------------------------------------------[INFO] Building simple-weather 1.0[INFO] ------------------------------------------------------------------------[INFO][INFO] --- exec-maven-plugin:1.3.1:java (default-cli) @ simple-weather ---[WARNING] Warning: killAfter is now deprecated. Do you need it ? Please comment on MEXEC-6.0 INFO YahooRetriever - Retrieving Weather Data411 INFO YahooParser - Creating XML Reader518 INFO YahooParser - Parsing XML Response559 INFO WeatherFormatter - Formatting Weather Data642 INFO mavenbook - ********************************* Current Weather Conditions for: Evanston, IL, US Temperature: 72 Condition: Partly Cloudy Humidity: 87 Wind Chill: 72*********************************[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 1.831s[INFO] Finished at: Wed Jun 25 10:21:45 CST 2014[INFO] Final Memory: 9M/23M[INFO] ------------------------------------------------------------------------