服务器上面不同jar包的多xml解析器冲突
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~[spring-beans-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
... 100 common frames omitted
Caused by: java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:234) ~[mybatis-3.5.6.jar!/:3.5.6]
at org.apache.ibatis.parsing.XPathParser.<init>(XPathParser.java:127) ~[mybatis-3.5.6.jar!/:3.5.6]
at org.apache.ibatis.builder.xml.XMLMapperBuilder.<init>(XMLMapperBuilder.java:81) ~[mybatis-3.5.6.jar!/:3.5.6]
at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.buildSqlSessionFactory(MybatisSqlSessionFactoryBean.java:592) ~[mybatis-plus-extension-3.4.1.jar!/:3.4.1]
at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.afterPropertiesSet(MybatisSqlSessionFactoryBean.java:431) ~[mybatis-plus-extension-3.4.1.jar!/:3.4.1]
at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.getObject(MybatisSqlSessionFactoryBean.java:628) ~[mybatis-plus-extension-3.4.1.jar!/:3.4.1]
at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration.sqlSessionFactory(MybatisPlusAutoConfiguration.java:218) ~[mybatis-plus-boot-starter-3.4.1.jar!/:3.4.1]
at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration$$EnhancerBySpringCGLIB$$838ac9e.CGLIB$sqlSessionFactory$1(<generated>) ~[mybatis-plus-boot-starter-3.4.1.jar!/:3.4.1]
at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration$$EnhancerBySpringCGLIB$$838ac9e$$FastClassBySpringCGLIB$$bdfc5147.invoke(<generated>) ~[mybatis-plus-boot-starter-3.4.1.jar!/:3.4.1]
1.配置jdk,在jdk中添加文件/jre/lib/jaxp.properties
文件内容:
javax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
2.或者在启动项里加:
System.setProperty(“javax.xml.parsers.DocumentBuilderFactory”,“com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl”);
@SpringBootApplication
public class AdminApplication {
public static void main(String[] args) {
System.setProperty("javax.xml.parsers.DocumentBuilderFactory","com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
SpringApplication.run(AdminApplication.class);
}
}
第二种方法在windows本地可以,在liunx上会不起作用