Получение ServiceConfigurationError: javax. xml .parsers.DocumentBuilderFactory при запуске тестового примера throw maven - PullRequest
0 голосов
/ 12 марта 2020

Я пытался запустить тест, который хорошо работает в IDE (как eclipse, так и Intellij). Однако, когда я попытался реализовать код, используя maven, он потерпел неудачу. Кроме того, я хотел бы сделать share, если я запускаю одиночный тестовый пример, используя mvn -Dtest=MessageSourceTests Командный тест пройден. Я пробовал многие вещи, как сделать excluding и including разные банки, но не сработало.

Это мой код на данный момент:

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.Test;
@Test
@ContextConfiguration(locations={"classpath:/messageSourceContext.xml"})
public class MessageSourceTests extends AbstractTestNGSpringContextTests {

   public void testMessageSource() {

       System.out.println("***********************done *****************");
       // Code to Read message source 
       }
}

Maven бросает Исключение:

springTestContextPrepareTestInstance(MessageSourceTests)  Time elapsed: 0.094 s  <<< FAILURE!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [messageSourceContext.xml]; nested exception is javax.xml.parsers.FactoryConfigurationError: Provider for class javax.xml.parsers.DocumentBuilderFactory cannot be created
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider for class javax.xml.parsers.DocumentBuilderFactory cannot be created
Caused by: java.lang.RuntimeException: Provider for class javax.xml.parsers.DocumentBuilderFactory cannot be created
Caused by: java.util.ServiceConfigurationError: javax.xml.parsers.DocumentBuilderFactory: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not a subtype

Любое предложение или направление для решения этой проблемы?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...