spring-3

Setting an active profile for AbstractAnnotationConfigDispatcherServletInitializer that can be use with @PropertySource?

一个人想着一个人 提交于 2019-12-04 11:25:43
I'm using the AbstractAnnotationConfigDispatcherServletInitializer to configure my web application. I also have an @Configuration class I use for creating a few beans. In this class, I use the @PropertySource annotation to load a properties file for various settings (e.g. database connection details). Currently, I use Maven profiles with Ant tasks to create the correct properties file(s) for my runtime environment. That is, I get Maven to move a "prod.properties" or "dev.properties" to "application.properties" (which the class uses) at build time. What I would like to do is use Spring profiles

PropertyPlaceholderConfigurer vs ReloadableResourceBundleMessageSource

你。 提交于 2019-12-04 09:47:27
Searching Google on how to configure property file in Spring 3 and I got many different answers. I found that ReloadableResourceBundleMessageSource and PropertyPlaceholderConfigurer can be used for getting properties from property files. Can somebody please explain the difference between these? PropertyPlaceholderConfigurer used for properties files to be used in the application context or inside the code with with @value. ResourceBundleMessageSource used for Internationalization & Localization (i18n) of messages you want to show to the user, within jsp direct, or from your code by wiring

Class not found CallableProcessingInterceptor: migrated to 3.1.4

淺唱寂寞╮ 提交于 2019-12-04 07:09:52
问题 Stack trace: SEVERE: Servlet /tsl threw load() exception java.lang.ClassNotFoundException: org.springframework.web.context.request.async.CallableProcessingInterceptor at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) at java.lang.Class

How to pool objects in Spring?

天涯浪子 提交于 2019-12-04 05:31:11
I'm following this tutorial regarding how to pool objects in Spring. I've followed the instruction written on the tutorial but when I run my application, it always generates a new instance of the object. I'm expecting that since I'm pooling the objects, existing objects will be reuse. As such, no new instances should be created. Also, when I access of the getter method of the bean, a new instance of the bean is created again. What could have I done wrong? Did I misunderstood the concept of pooling in Spring? Below is my code: Application Context: (This is just the body of my application

Connecting to JMX server in spring throws exception!

一笑奈何 提交于 2019-12-04 05:00:48
So when I try to connect to jmx from jconsole I get this exception: Caused by: java.rmi.ConnectException: Connection refused to host: 78.84.17.116; nested exception is: java.net.ConnectException: Connection timed out: connect at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601) at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198) ... I was trying to connect to such url in jconsole: service:jmx:rmi:///jndi/rmi://78.84.17.116:43030/test My jmx spring configuration: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema

@Autowired and @Service working from controller but not from a different package

旧城冷巷雨未停 提交于 2019-12-03 17:15:48
问题 I need help understanding the concept behind @Autowired and @Service . I have a DAO defined with @Service and controller with @Autowired and everything seems fine, however, I use the same @Autowired in a different class then it does not work. Example: Service @Service public class MyService { private JdbcTemplate jdbcTemplate; @Autowired public void setDataSource (DataSource myDataSource) { this.jdbcTemplate = new JdbcTemplate(myDataSource); } public void testUpdate(){ jdbcTemplate.update(

Generate full XML configuration from Spring 3 annotations

吃可爱长大的小学妹 提交于 2019-12-03 12:59:06
Is there is a way to generate full XML configuration file based on Spring 3 annotations scattered all over the classes? Ideally, I'm looking for a tool that can "parse" a Spring 3 project and output XML configuration, something like xdoclet was doing (but off course from Spring annotations) Is there a tool like this, or a way I could write my own if none exists? You can always write your own. I'm not aware of one. Funny, because annotations were added because some people complained about heavy XML configuration. You're swimming against the tide here. Just curious - why do you want the XML now?

How update/remove an item already cached within a collection of items

泄露秘密 提交于 2019-12-03 12:36:39
I am working with Spring and EhCache I have the following method @Override @Cacheable(value="products", key="#root.target.PRODUCTS") public Set<Product> findAll() { return new LinkedHashSet<>(this.productRepository.findAll()); } I have other methods working with @Cacheable and @CachePut and @CacheEvict. Now, imagine the database returns 100 products and they are cached through key="#root.target.PRODUCTS" , then other method would insert - update - deleted an item into the database. Therefore the products cached through the key="#root.target.PRODUCTS" are not the same anymore such as the

Spring 3 Security j_spring_security_check

不问归期 提交于 2019-12-03 12:16:12
I'm trying to learn, how spring security works, so I've downloaded some sample project and then I tried to implement that solution to my project. But when I try to login, I get 404 error and in an address bar I have http://localhost:8080/fit/j_spring_security_check . I tried to look at similar questions here, but I wasn't able to realize, how to apply it to my project. I'd be really thankful, if somebody, who is more experienced, could help me. My app structure looks like this: applicationContext.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema

Jetty addFilter with Spring Security and no web.xml

為{幸葍}努か 提交于 2019-12-03 12:06:21
问题 Normally I would have added org.springframework.web.filter.DelegatingFilterProxy with a snippet like this to web.xml: <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class> org.springframework.web.filter.DelegatingFilterProxy </filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> But with Servlet 3.0 Container and Jetty, I've removed web.xml. I'm trying to add DelegatingFilterProxy