所有,與Spring 3.0參考號/ Hibernate的配置文件
我原本我的設置是這樣,一切工作正常。
WEB-INF
|--spring-servlet.xml
|--classes
|--hibernate-cfg.xml
爲spring-servlet.xml有
<context:component-scan base-package="foo" />
<tx:annotation-driven/>
<bean id="dataSource" ...
<bean id="sessionFactory" ...
<bean id="transactionManager" ...
<bean ...
休眠-cfg.xml中有
<hibernate-configuration>
<session-factory>
<mapping ...
我想Spring Security的加進來來處理用戶身份驗證。爲了使這個工作,我不得不重構一些東西。我的新的設置是這樣的:
WEB-INF
|--spring-servlet.xml
|--classes
|--datasource-cfg.xml
|--hibernate-cfg.xml
爲spring-servlet.xml有
<context:component-scan base-package="foo" />
<bean ...
數據源-cfg.xml中有
<tx:annotation-driven/>
<bean id="dataSource" ...
<bean id="sessionFactory" ...
<bean id="transactionManager" ...
休眠-cfg.xml中有
<hibernate-configuration>
<session-factory>
<mapping ...
驗證件現在可以工作,但以前的工件不再工作。
我現在得到以下信息:
No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:687)
我怎樣才能得到我的應用程序與春季安全工作,並擁有所有的數據源/在一個地方冬眠的東西?
你如何配置spring使用額外的配置文件? –
啊,你可能會想到什麼。 Spring Security使您可以將它添加到web.xml中的類路徑中。 <的context-param> contextConfigLocation的 /WEB-INF/spring-security.xml 類路徑:數據源-cfg.xml中 PARAM值> 的context-param> –
user973479
我不知道如何添加類路徑,以便應用程序的其餘部分可以看到datasource-cfg.xml是否將添加到spring-servlet.xml,web.xml等? – user973479