我意识到会有人想要将此标记为重复,但我已尝试过在stackflow中看到的所有解决方案,但没有运气。请问有人能告诉我究竟是什么问题吗?
我将Spring启动服务部署到weblogic12c后出现错误:
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectWriter.forType(Lcom/fasterxml/jackson/databind/JavaType;)Lcom/fasterxml/jackson/databind/ObjectWriter;
我已将库添加到$ DOMAIN / lib目录中,我看到它们在启动时加载:
<Mar 6, 2018 12:58:37 PM EST> <Notice> <WebLogicServer> <BEA-000395> <The following extensions directory contents added to the end of the classpath:
C:\Oracle_12c_Home\user_projects\domains\fsma_3\lib\jackson-annotations-2.8.8.jar;C:\Oracle_12c_Home\user_projects\domains\fsma_3\lib\jackson-core-2.8.8.jar;C:\Oracle_12c_Home\user_projects\domains\fsma_3\lib\jackson-databind-2.8.8.jar.>
我注意到com.fasterxml:classmate = com.fasterxml:classmate:jar:1.3.3:compile,正在构建中编译。这与杰克逊图书馆不兼容吗?
这是我的pom.xml的相关部分:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<!-- <version>2.8.8</version> -->
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<!-- <version>2.8.8</version> -->
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<!-- <version>2.8.8</version> -->
</dependency>
这是我的dispatcherServlent.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<mvc:annotation-driven/> <!-- Must require to enable @ResponseBody annotation -->
</beans>
这是weblogic.xml:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
http://xmlns.oracle.com/weblogic/weblogic-web-app
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:container-descriptor>
<!--<wls:index-directory-enabled>true</wls:index-directory-enabled> -->
<wls:prefer-application-packages>
<wls:package-name>org.slf4j</wls:package-name>
<wls:package-name>org.springframework.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
<wls:context-root>spring-boot-pcocar</wls:context-root>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>com.fasterxml</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
<!-- <security-role-assignment>
<role-name>PC_OCAR_GROUP</role-name>
<principal-name>pcocar</principal-name>
</security-role-assignment> -->
这是web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>gov.fda.furls.fsma.pcocar.Application</param-value>
</context-param>
<listener>
<listener-class>org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>metricFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>metricFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextAttribute</param-name>
<param-value>org.springframework.web.context.WebApplicationContext.ROOT</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- <security-constraint>
<web-resource-collection>
<web-resource-name>Access to the entire application</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>POST</http-method>
<http-method>PUT</http-method>
<http-method>GET</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>PC_OCAR_GROUP</role-name>
</auth-constraint>
<user-data-constraint>
<description>SSL not required</description>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>pcocar</realm-name>
</login-config>
<security-role>
<role-name>PC_OCAR_GROUP</role-name>
</security-role> -->
答案 0 :(得分:0)
我很遗憾地说解决方案很简单,我在weblogic.xml文件中做错了。
所以这就是你需要在weblogic.xml文件中做的事情:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:container-descriptor>
<!--<wls:index-directory-enabled>true</wls:index-directory-enabled> -->
<wls:prefer-application-packages>
<wls:package-name>org.slf4j</wls:package-name>
<wls:package-name>org.springframework.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
<wls:context-root>spring-boot-pcocar</wls:context-root>
</wls:weblogic-web-app>
删除pom.xml中对com.fasterxml.jackson.core的所有引用,然后它将部署并运行。