- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 'dataSource' bean 是在 dao-context.xml 中定义的,就像这样
<bean name="hcpDS" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" >
<property name="driverClassName" value="${hcp.connection.driver_class}" />
<property name="username" value="${hcp.connection.username}" />
<property name="password" value="${hcp.connection.password}" />
<property name="url" value="${hcp.connection.url}" />
<property name="maxIdle" value="${hcp.minPoolSize}" />
<property name="maxActive" value="${hcp.maxPoolSize}" />
</bean>
<beans:bean class="org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl" id="userDetailsService">
<beans:property name="rolePrefix" value="ROLE_"/>
<beans:property name="dataSource" ref="dataSource"/>
<beans:property name="usersByUsernameQuery" value="SELECT username,password,enabled FROM Users WHERE username = ?"/>
<beans:property name="authoritiesByUsernameQuery" value="SELECT u.username, a.authorityname FROM Users u JOIN Users_Authorities ua on u.id = ua.user_id JOIN Authorities a on ua.authorities_id = a.id WHERE u.username = ?"/>
</beans:bean>
2014-06-08 16:10:06,683 ERROR [localhost-startStop-1] ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': Cannot create inner bean '(inner bean)' of type [org.springframework.security.config.authentication.AuthenticationManagerFactoryBean] while setting bean property 'parent'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting bean property 'providers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'userDetailsService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService' defined in class path resource [HCP-security-context.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jee="http://www.springframework.org/schema/jee"
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/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
<import resource="classpath:HCP-security-context.xml" />
<import resource="classpath:HCP-service-context.xml" />
<import resource="classpath:HCP-dao-context.xml" />
</beans>
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name></display-name>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<filter>
<description>
generated-spring-security-session-integration-filter
</description>
<filter-name>
SpringSecuritySessionIntegrationFilter
</filter-name>
<filter-class>
org.springframework.security.web.context.SecurityContextPersistenceFilter
</filter-class>
</filter>
<filter>
<description>generated-spring-security-filter</description>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>
SpringSecuritySessionIntegrationFilter
</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<description>generated-persistence-filter</description>
<filter-name>hcpFilter</filter-name>
<filter-class>
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
</filter-class>
<init-param>
<param-name>entityManagerFactoryBeanName</param-name>
<param-value>hcp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>hcpFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>sunny</param-value>
</context-param>
<welcome-file-list>
<welcome-file>template.xhtml
</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<description>servlet</description>
<servlet-name>HCP Servlet</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:HCP-web-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<description>resources-servlet</description>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>
org.springframework.js.resource.ResourceServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
</web-app>
最佳答案
使用 name="dataSource"
重命名数据源 bean id你必须import dao-context.xml
内security-context.xml
为了使用 dataSource bean。
关于spring - 如何解决 spring 没有定义名为 'dataSource' 的 bean?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24108193/
更新:将代码更改为立即调用并分配 dataSource ,但我仍然遇到相同的结果,但 sourceData.paginator 正在运行。 sourceData.filter 和 sourceData
我想以编程方式设置我的数据源的模型。像这样的东西: var ds = new kendo.data.DataSource({ //... }); var mod = kendo.data.Model.
我有一个多模块 maven 项目,我想将它与 一起使用tomcat7 maven插件并开始: mvn tomcat7:run 但我不知道如何配置 jndi 数据源。 我试图放入我的 pom.xml:
任何人都可以提供有关如何执行此操作的说明吗?我设置了几个不同的 JDBC 数据源,并希望能够配置用户使用不同的数据源运行相同的报告。例如。当用户A登录并运行报表A时,使用数据源1;当用户 B 登录并运
过去几周我从这个网站收集了许多有用的答案。我加入是为了对一些我认为最有帮助的答案+1,但目前还无法做到这一点。不过谢谢! 我的问题是 JBoss 7 AS 部署错误,我似乎无法追踪任何相关信息。它开始
我们遇到了一个 problem哪里 我们在一个 MDI 工作区中有两个相同窗口的实例,它们绑定(bind)到两个单独的对象模型。 对象模型覆盖了它们的 .Equals 和 .GetHashCode 方
当我运行我的独立 Web 应用程序时,spring 无法实例化数据源 bean。请注意,我不想在此项目中使用 JPA 或休眠。在这一点上我不知道为什么。我最好的猜测是依赖项或语法问题,但我无法找到解决
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我的项目使用springBoot2,并且不需要连接数据库,但是springboot自动配置数据源并在启动项目时抛出异常。我已经添加了执行,但它不起作用 @SpringBootApplication(e
我指的是下面的链接来设置环回框架并创建简单的 API https://docs.strongloop.com/display/public/LB/Getting+started+with+LoopBa
我在 SPringBoot 中的数据源有问题。我想使用 JDBC 并从数据源获取数据,但出现错误:说明: com.example.My.MyApplication 中的字段 dataSource 需要
这是在我的 spring-servlet.xml 文件中定义的具有此 id 的 bean 这是完整的堆栈跟踪 SEVERE: Exception sending context initialize
我正在尝试使用 Spring、Maven 和 Hibernate 创建一个访问 sql server 数据库的应用程序。当我尝试运行应用程序时出现以下错误: Exception in thread "
当我运行我的网络应用程序时抛出以下错误。 Exception encountered during context initialization - cancelling refresh attemp
我正在研究 Spring Boot JDBC MYSQL 示例。在这个例子中,我使用了 1.3.1.RELEASE spring boot starter 版本,当时我使用了以下 2 spring.d
Feb 20, 2012 6:30:45 AM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring ro
我引用了网址:https://o7planning.org/en/11727/understanding-spring-cloud-config-client-with-example没有任何自定义,
spring.jpa.hibernate.ddl-auto=update spring.datasource.url=jdbc:mysql://localhost:3306/study?serverT
我有一个多线程作业(同时运行 6 个作业),这些作业使用 3 个数据源(第一个数据源上有 2 个,第二个数据源上有另外 2 个,第三个数据源上有最后 2 个)。 /* *************
我正在尝试实现从CurrencyExchange模块到CurrencyConvert的开放字段调用,但我被这个错误卡住了。有谁能帮帮我吗?我已经检查了其他答案,并试图添加#spring.datasou
我是一名优秀的程序员,十分优秀!