我正在尝试将基于Rest的Web服务应用程序部署到Weblogic控制台12C上。为此,我使用了Spring-Jersey实现和Spring依赖注入 在尝试访问我的服务时,我必须使用Weblogic的/ resources / *路径,因为/ rest / *不起作用。此外,SpringServlet没有被调用,但Weblogic自己的JAX-RS Jersey实现正在运行。我已经检查过,在应用程序启动期间,bean正在通过弹簧正确创建 任何人都可以提供有关如何使用我的实现而不是Weblogic的默认JAX-RS解决方案的解决方案。
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_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>TestWeb</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:testWebContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>jersey</servlet-name>
<servlet-class>
com.sun.jersey.spi.spring.container.servlet.SpringServlet
</servlet-class>
<init-param>
<param-name>POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.test.web.service</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
&#13;
testWebContext.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="testWebService" class="com.test.web.service.TestWebServiceImpl">
<property name="testWebBo" ref="testWebBo"/>
</bean>
<bean id="testWebBo" class="com.test.web.bo.TestWebBOImpl"/>
<bean name="destReader" init-method="readDestinations" class="com.test.web.util.DestinationReader"/>
</beans>
&#13;
答案 0 :(得分:0)
将weblogic.xml文件插入已部署应用的WEB-INF文件夹中。
这里有一个示例文件:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
<library-ref>
<library-name>jax-rs</library-name>
<specification-version>2.0</specification-version>
<implementation-version>2.5.1</implementation-version>
<exact-match>false</exact-match>
</library-ref>
<container-descriptor>
<prefer-application-packages>
<package-name>org.glassfish.jersey.client.*</package-name>
<package-name>org.glassfish.jersey.servlet.*</package-name>
<package-name>org.glassfish.jersey.jaxb.internal.*</package-name>
<package-name>com.sun.research.ws.wadl.*</package-name>
<package-name>org.glassfish.hk2.*</package-name>
<package-name>org.jvnet.hk2.*</package-name>
<package-name>jersey.repackaged.org.objectweb.asm.*</package-name>
<package-name>org.objectweb.asm.*</package-name>
<package-name>com.sun.ws.rs.ext.*</package-name>
<package-name>org.aopalliance.*</package-name>
<package-name>javax.annotation.*</package-name>
<package-name>javax.inject.*</package-name>
<package-name>javax.ws.rs.*</package-name>
<package-name>jersey.repackaged.com.google.common.*</package-name>
<package-name>javassist.*</package-name>
</prefer-application-packages>
</container-descriptor>
<context-root>your root name</context-root>
</weblogic-web-app>