spring-3

Is there any way to override a bean discovered by component scan?

笑着哭i 提交于 2019-12-19 05:13:27
问题 I have a java configuration class providing fooBean directly and barBean by component scan. @Configuration @ComponentScan(basePackages = { "com.blah" }) public class Config { @Bean public FooBean fooBean { return new FooBean(); } } and i want to reuse it in the test cases and i need to replace the beans with mocks: @Configuration @Import(Config.class) public class TestConfig { @Bean public FooBean fooBean { return new FooBeanMock(); } @Bean public BarBean barBean { return new BarBeanMock(); }

Support both jsp and jspx in spring 3.0

柔情痞子 提交于 2019-12-19 03:58:52
问题 i've set up a roo application. The default view resolver built-in in roo is for jspx files. Is it possible to support also jsp files?. I tried configuring two viewResolvers but it seems that no urlBasedViewResolvers can coexist, its either one or the other. Changing the order does not affect the behaviour. If I set order =1 to the jspx then if i search for any .jsp file it gives me 404. The same if I search for jspx but jsp viewResolver is set with order =1. Is there anyway to do this? Thanks

Cannot find Spring MVC project when creating new web application project using STS?

£可爱£侵袭症+ 提交于 2019-12-19 03:43:14
问题 I'm new to Spring MVC and trying to learn from the internet tutorial such as these good ones from journaldev, springsource, and codejava All of those tell me use STS as the IDE and to go for New Project - Spring Template Project - Spring MVC Project . Though in my case, using the version 3.6.1.RELEASE of STS, I can NOT find any Spring MVC Project options there. Do you have the same issue using STS? p.s. I found the solution here for previous version of STS, though it not works for version 3.6

Spring security logout goes to j_spring_security_logout

独自空忆成欢 提交于 2019-12-18 16:48:08
问题 In my web application when I tries to logout it goes to j_spring_security_logout instead of the given page. In my spring-security.xml page i have added <logout logout-success-url="/login" delete-cookies="JSESSIONID" /> The problem is this worked earlier when I used spring security 3.1.4.RELEASE version. Now I'm using 3.2.2.RELEASE I've tried the following also. Didn't work <logout logout-url="/logout" delete-cookies="JSESSIONID" /> spring-security.xml <beans:beans xmlns="http://www

Spring security logout goes to j_spring_security_logout

南楼画角 提交于 2019-12-18 16:47:34
问题 In my web application when I tries to logout it goes to j_spring_security_logout instead of the given page. In my spring-security.xml page i have added <logout logout-success-url="/login" delete-cookies="JSESSIONID" /> The problem is this worked earlier when I used spring security 3.1.4.RELEASE version. Now I'm using 3.2.2.RELEASE I've tried the following also. Didn't work <logout logout-url="/logout" delete-cookies="JSESSIONID" /> spring-security.xml <beans:beans xmlns="http://www

Spring3 's @Transactional @Scheduled not committed to DB?

别来无恙 提交于 2019-12-18 16:31:11
问题 This is my 1st time trying Spring3's @Scheduled , but found I cannot commit to DB. This is my code : @Service public class ServiceImpl implements Service , Serializable { @Inject private Dao dao; @Override @Scheduled(cron="0 0 * * * ?") @Transactional(rollbackFor=Exception.class) public void hourly() { // get xxx from dao , modify it dao.update(xxx); } } I think it should work , I can see it starts-up hourly and load xxx from DB , but data is not committed to DB. There's been tx:annotation

Change @ManagedResource objectName dynamically

早过忘川 提交于 2019-12-18 15:54:27
问题 I am creating prototype beans programatically/dynamically. I want those beans after initiation to be in the jmx console. How I can distinguish between them? I am using anotations in order to add my beans to the jmx and I have @ManagedResource(objectName="bean:name=MybBean") I need to inject the objectName dynamically. Any idea how could I do it? Here's my jmx configuration: <context:mbean-export server="mbeanServer" /> <bean id="mbeanServer" class="org.springframework.jmx.support

In Spring 3.1 can <mvc:interceptors> be used in conjunction with @Configuration

喜欢而已 提交于 2019-12-18 13:39:07
问题 I am migration from Spring 3.0.5 to 3.1 since I need to have custom RequestMappingHandlerMapping. I am facing problems in plug-in of extended RequestMappingHandlerMapping - I had existing servlet-conetxt.xml and I added WebConfig with @Configuration annotation. But, I always get error ambiguos mapping (since new annotation defined in ExtendedRequestMappingHandlerMapping is not takign in effect). I have various levels of interceptors defined in servlet-context.xml which I want to keep in XML

No persistence exception translators found in bean factory. Cannot perform exception translation

一个人想着一个人 提交于 2019-12-18 03:51:56
问题 I'm getting following exception after migrating to Spring Framework 3.1.0 RC1 with Hibernate 4.0.0 CR7 2011-12-08/11:48:38.425/EST [Thread-17] ERROR Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is java.lang

“The matching wildcard is strict, but no declaration can be found for element 'http'” Error

心不动则不痛 提交于 2019-12-17 19:13:12
问题 I am trying to configure NTLM authentication, but receive error: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'http'. I read a lot of topics with a similar error, but I could not find a solution to my problem. My security.xml file that causes an error is: <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi