小编Mat*_*ner的帖子

如何通过XML配置Spring Social

我花了几个小时试图让Twitter集成与Spring Social一起使用XML配置方法.我可以在Web上(以及在stackoverflow上)找到的所有示例始终使用示例中@Config显示的方法

无论出于何种原因,获取twitter API实例的bean定义都会引发AOP异常:

Caused by: java.lang.IllegalStateException: Cannot create scoped proxy for bean 'scopedTarget.twitter': Target type could not be determined at the time of proxy creation.
Run Code Online (Sandbox Code Playgroud)

这是我的完整配置文件:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:jaxrs="http://cxf.apache.org/jaxrs"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:util="http://www.springframework.org/schema/util" 
    xmlns:cxf="http://cxf.apache.org/core"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:jdbc="http://www.springframework.org/schema/jdbc"  
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
       http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
       http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
       http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd">

    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

    <jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/DefaultDB" />

    <!-- initialize DB required to store …
Run Code Online (Sandbox Code Playgroud)

aop spring spring-aop xml-configuration spring-social

8
推荐指数
1
解决办法
7522
查看次数

Spring Boot仍然需要web.xml中的resource-ref

现在查看Spring Boot并希望正确地执行它,就像使用Java配置一样,最终没有任何配置web.xml.因此,棘手的部分是生产环境需要经典WAR文件.

因此,我WAR在Maven pom.xml文件中指定了包装,主要的Application类扩展了SpringBootServletInitializer.

工作得很好.现在,棘手的部分是在生产环境中Datasource通过提供JNDI.在经典的Spring应用程序中,您将在web.xml使用a中引用此依赖项,resource-ref如下所示:

 <resource-ref>
    <res-ref-name>jdbc/DefaultDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
</resource-ref>
Run Code Online (Sandbox Code Playgroud)

我所做的所有研究似乎表明我可以摆脱web.xml它并用相应的context.xml文件替换它(在META-INF文件夹中):

   <Resource name="jdbc/DefaultDB"
          auth="Container"
          type="javax.sql.DataSource"
          factory="com.sap.jpaas.service.persistence.core.JNDIDataSourceFactory"/>
Run Code Online (Sandbox Code Playgroud)

不幸的是,这不起作用:/

有趣的是,一个简单的servlet3 Web应用程序就可以正常工作,请参阅[ https://github.com/steinermatt/servlet3-sample].

因此,我很想相信它对Spring Boot应用程序不起作用的根本原因与Spring Boot引导程序有关......所以,真正寻找任何提示,建议它可能是什么!

任何帮助表示赞赏!

spring servlet-3.0 spring-boot

7
推荐指数
1
解决办法
1578
查看次数