Я начал новый maven-проект с maven-archetype-quickstart.Я использую Eclipse Java EE IDE для веб-разработчиков в версии: выпуск Oxygen.3a (4.7.3a), идентификатор сборки: 20180405-1200 в Ubuntu 17.10.
Мой POM.XML
<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>
<groupId>org.rogatio</groupId>
<artifactId>helloworld</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>helloworld</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<systemProperties>
<property>
<name>log4j.configurationFile</name>
<value>log4j2.properties</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
Главный класс - это пакет org.rogatio.helloworld;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class App {
final static Logger logger = LogManager.getLogger(App.class);
public static void main(String[] args) {
logger.info("App started.");
System.out.println("Hello World!");
sayHi();
}
public static String sayHi() {
logger.info("Hi!");
System.out.println("Hi!");
return "Hi!";
}
}
Моя структура проекта -
![Filestructure](https://i.stack.imgur.com/2KnzF.png)
Test-Class -
package org.rogatio.helloworld;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
public void testApp()
{
assertTrue( true );
}
public void testHi()
{
assertEquals( App.sayHi(), "Hi!" );
}
}
Проблема в том, что при запуске Maven-Test выдает
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.rogatio.helloworld.AppTest
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
Hi!
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.233 sec - in org.rogatio.helloworld.AppTest
Также при запуске приложения выдает
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
Hello World!
Hi!
Я не понял, что не так.Все установлено, и ресурсы находятся в classpath.Есть идеи, что не так?Мой POM неверен?
Вы можете найти полный проект под https://ufile.io/8zy0a