spring-4

Spring async method called from another async method

社会主义新天地 提交于 2019-12-28 11:53:14
问题 I'm using Spring 4 and I've noticed an odd behaviour... if I'm calling an async method multiple times from a normal instance method then they are all called in different threads and finish at random times. But if I call multiple times an async method from another async method then they finish in order. I have something like this: @Async public void nonAsyncMethod() { for (int i = 0; i < 30; i++) { asyncMethod(); } } @Async public void asyncMethod() { ... something here } I'm using the default

Spring async method called from another async method

只谈情不闲聊 提交于 2019-12-28 11:53:13
问题 I'm using Spring 4 and I've noticed an odd behaviour... if I'm calling an async method multiple times from a normal instance method then they are all called in different threads and finish at random times. But if I call multiple times an async method from another async method then they finish in order. I have something like this: @Async public void nonAsyncMethod() { for (int i = 0; i < 30; i++) { asyncMethod(); } } @Async public void asyncMethod() { ... something here } I'm using the default

Spring 4 autowiring of generic classes works in test, doesn't work when deployed to server

♀尐吖头ヾ 提交于 2019-12-25 06:46:50
问题 I have generic classes which autowires dependencies based on their generic type like this: public abstract class GenericRestService<C extends AbstractTenantEntity> extends RestResource<C> { protected final Logger log; @Autowired(required = false) protected GenericResourceService<C> service; @Autowired(required = true) protected JpaRepository<C, Long> repo; // Now use service if one with specified generic type C is found, otherwise use repo In my spring tests everything works: if no

Conditional validation in spring mvc

China☆狼群 提交于 2019-12-25 02:53:27
问题 Now I have following controller method signature: @ResponseBody @RequestMapping(value = "/member/createCompany/addParams", method = RequestMethod.POST) public ResponseEntity setCompanyParams( @RequestParam("companyName") String companyName, @RequestParam("email") String email, HttpSession session, Principal principal) throws Exception {...} I need to add validation for input parameters. Now I am going to create object like this: class MyDto{ @NotEmpty String companyName; @Email // should be

BeanNameAutoProxyCreator setBeanNames regular expression not working?

心已入冬 提交于 2019-12-25 01:55:42
问题 This is my BeanNameAutoProxyCreator : @Bean public BeanNameAutoProxyCreator beanNameAutoProxyCreator() { BeanNameAutoProxyCreator beanNameAutoProxyCreator = new BeanNameAutoProxyCreator(); beanNameAutoProxyCreator.setBeanNames("*service"); // If i put "*Service" instead, then i get an exception. beanNameAutoProxyCreator.setInterceptorNames("loggingAdvice", "debugInterceptor"); return beanNameAutoProxyCreator; } @Bean public LoggingAdvice loggingAdvice() { return new LoggingAdvice(); } @Bean

Spring 4 binaries download

我与影子孤独终老i 提交于 2019-12-23 20:17:50
问题 I haven't downloaded spring in a while. I'm investigating gradle, but don't seem to have the hang of it yet, so i want to create a new spring framework project using java, Spring 4 and ant. I can't seem to find the place to download the binaries for Spring 4. Are they just kicking ant developers under the bus? 回答1: Maven and Gradle are the preferred ways to use Spring Framework in your project, but dist ZIPs are still available on the official repository. 回答2: Are they just kicking ant

Spring 4 MVC - Rest service - use default values in beans

元气小坏坏 提交于 2019-12-23 09:46:37
问题 I am using Spring 4.1.4 and implementing a simple REST service. I do have a POST method which gets a Person object as request. @ResponseStatus(value = HttpStatus.CREATED) @RequestMapping(value = "", method = RequestMethod.POST, headers = "Accept=application/json", consumes = "application/json") public void add(@Valid @RequestBody Person oPerson) throws Exception { //do the things } Bean: public class Person { public Person(){ } private String firstname; private String lastname; private

Getting a Loop Redirect with Spring Security + CAS, but should be working

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 09:09:46
问题 I'm trying to change a basic application from using only Spring Security to using CAS, to enable SSO. But i'm getting a redirect loop somewhere, and i can't find out what is wrong. I have made two other mock applications, and there's no problem on CAS, because they are working. I'm using the Java configuration in place of the XML one, taken from here. I've tried the XML configuration for the example, but i'm still getting the same result. My guess would be for a problem with the

Getting a Loop Redirect with Spring Security + CAS, but should be working

夙愿已清 提交于 2019-12-23 09:09:03
问题 I'm trying to change a basic application from using only Spring Security to using CAS, to enable SSO. But i'm getting a redirect loop somewhere, and i can't find out what is wrong. I have made two other mock applications, and there's no problem on CAS, because they are working. I'm using the Java configuration in place of the XML one, taken from here. I've tried the XML configuration for the example, but i'm still getting the same result. My guess would be for a problem with the

No mapping found for HTTP request with URI (spring 4.1 annotation configuration)

跟風遠走 提交于 2019-12-23 02:03:24
问题 first of all, please don't lock this thread, please. I've read all the questions, and they still cannot solve my problem. I'm studying how to use annotation on spring without configuring xml files. I'm stucking with the error: No mapping found for HTTP request with URI [/WEB-INF/index.jsp] in DispatcherServlet with name 'dispatcherServlet' This is the project structure This my pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http:/