spring-4

Programmatic SchemaExport / SchemaUpdate with Hibernate 5 and Spring 4

不羁岁月 提交于 2019-11-28 09:41:55
With Spring 4 and Hibernate 4, I was able to use Reflection to get the Hibernate Configuration object from the current environment, using this code: @Autowired LocalContainerEntityManagerFactoryBean lcemfb; EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) lcemfb.getNativeEntityManagerFactory(); SessionFactoryImpl sf = emf.getSessionFactory(); SessionFactoryServiceRegistryImpl serviceRegistry = (SessionFactoryServiceRegistryImpl) sf.getServiceRegistry(); Configuration cfg = null; try { Field field = SessionFactoryServiceRegistryImpl.class.getDeclaredField("configuration"); field

Changing password using Spring security

北慕城南 提交于 2019-11-28 06:13:27
问题 I use, Spring Framework 4.0.0 RELEASE (GA) Spring Security 3.2.0 RELEASE (GA) Struts 2.3.16 in which I use, org.springframework.security.authentication.dao.DaoAuthenticationProvider for authentication. My spring-security.xml file looks like the following. <?xml version="1.0" encoding="UTF-8"?> <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:schemaLocation=

Stomp over websocket : The send buffer size exceeded the allowed limit

元气小坏坏 提交于 2019-11-28 03:40:01
问题 At client side I am using Stomp for websocket connection and server side I am using Spring 4 It client side I did configuration as var socket = new SockJS(urlBase + "/" + contextroot+'/hello'); stompClient = Stomp.over(socket); Below code executed for every 2 second to send data to server stompClient.send('/app/sendRequest/'+indexVal, {}, JSON.stringify({index : simIndex})); Server respond to below queue stompClient.subscribe('/queue/response', processResponseObj); at server side

How to use JasperReports with Spring MVC?

…衆ロ難τιáo~ 提交于 2019-11-28 02:59:21
I've been investigating the use of JasperReports (6.0.0) with Spring MVC (4.1.3) to generate PDF reports. Spring is rife with "Spring specific" ways to integrate with JasperReports to generate PDFs: Use JasperReportsPdfView relies on now deprecated JasperReport features Use JasperReportsMultiFormatView Use JasperReportsViewResolver I struggled to find good, complete examples online and wanted to share my findings (see my answer below ). Feel free to add additional methods and/or improvements related to "How can I integrate JasperReports with Spring4"? Based on my research, I've found the

Difference between @EntityScan and @ComponentScan

人走茶凉 提交于 2019-11-27 19:37:02
I am trying to understand the difference here. I see that a class has been annotated with both of them with same package example : @Configuration @EntityScan("some.known.persistence") @ComponentScan({ "some.known.persistence"}) public class ApiConfig { } I understand the differences from API docs but want to understand in detail. Also does it mean that anything that is scanned by @ComponentScan is having wider visibility wrt Spring context and @EntityScan does not. If so using some attribute with @ComponentScan should have sufficed the need to bind in a JPA context, isn't it? The

Multiple scenarios @RequestMapping produces JSON/XML together with Accept or ResponseEntity

跟風遠走 提交于 2019-11-27 19:18:51
I am working with Spring 4.0.7 About Spring MVC, for research purposes, I have the following: @RequestMapping(value="/getjsonperson", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Person getJSONPerson(){ logger.info("getJSONPerson - getjsonperson"); return PersonFactory.createPerson(); } @RequestMapping(value="/getperson.json", method=RequestMethod.GET) public @ResponseBody Person getPersonJSON(){ logger.info("getPerson - getpersonJSON"); return PersonFactory.createPerson(); } Each one works fine, observe both for JSON, with and without extension:

SpringMVC: Inconsistent mapping behavior depending on url extension

不想你离开。 提交于 2019-11-27 18:09:03
问题 I have a RESTful spring based endpoint to get assets stored in a db to a javascript editor. The relevant parts boil down to: @RestController @RequestMapping(ThemeEndpoint.ENDPOINT_NAME) public class ThemeEndpoint { public static final String ENDPOINT_NAME = "/themes"; @RequestMapping(value="/{id}/css/{assetName:.*}", method=RequestMethod.GET) public Asset getCssItem( @PathVariable("id") ThemeId id, @PathVariable("assetName") String name) { CssThemeAsset themeAsset = themeService.getCssAsset(

Relation between WebSecurityConfigurerAdapter and ResourceServerConfigurerAdapter

六眼飞鱼酱① 提交于 2019-11-27 11:10:35
问题 I'm trying to integrate Spring OAuth2 into Spring MVC REST. Most of the Spring OAuth2 examples, there is only ResourceServerConfigurerAdapter and some of have WebSecurityConfigurerAdapter as well. I'm not going to integrate OAuth with Google, Facebook, etc. I'm trying to provide a token based authentication for Spring MVC REST which is currently based on Basic Authentication. Can someone exaplin me what is required and not or good resource to understand the Spring MVC REST +OAuth integration

When use AbstractAnnotationConfigDispatcherServletInitializer and WebApplicationInitializer?

徘徊边缘 提交于 2019-11-27 09:01:37
问题 I am working with Spring 4.0.7 I did a research about configure Spring MVC through JavaConfig. Practically until yesterday I have seen two configurations using these two options extends AbstractAnnotationConfigDispatcherServletInitializer extends WebMvcConfigurerAdapter and implements WebApplicationInitializer Note : (2) are two classes, one for extension and the other for implementation I am using (2) because I have found many examples where I am able to configure converters, formatters,

AbstractMethodError on deploying Spring 4.0 in Tomcat 6

匆匆过客 提交于 2019-11-27 07:45:58
I am getting below exception on deploying Spring 4.0.1 app in Tomcat 6.0.37: SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.hibernate.validator.internal.engine.ConfigurationImpl.getDefaultParameterNameProvider()Ljavax/validation/ParameterNameProvider; at