applicationcontext

PropertyPlaceholderConfigurer and environment variables in .properties files

南楼画角 提交于 2019-11-30 02:31:29
I have a Spring application-context.xml with PropertyPlaceholderConfigurer to get properties' values from .properties file. Main and test source folders have separate .properties file. The issue is that I need to use environment variables in .properties file. But when I do it in the following way: property.name=${env.SYSTEM_PROPERTY} I'm getting the following error: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'beanName' defined in class path resource [com/example/applicationContext.xml]: Could not resolve placeholder 'env.SYSTEM_PROPERTY'

Spring ApplicationListener is not receiving events

﹥>﹥吖頭↗ 提交于 2019-11-29 22:52:23
I have the following ApplicationListener: package org.mycompany.listeners; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextStartedEvent; public class MyApplicationListener implements ApplicationListener<ContextStartedEvent> { public MyApplicationListener() { super(); System.out.println("Application context listener is created!"); } /** * {@inheritDoc} */ public void onApplicationEvent(final ContextStartedEvent event) { System.out.println("Context '" + event.getApplicationContext().getDisplayName() + "' is started!"); } } And the following

ApplicationContext and ServletContext

有些话、适合烂在心里 提交于 2019-11-29 22:25:57
I get confused between the two ApplicationContext and ServletContext when it comes to Spring MVC Application. I know that There is just only One ApplicationContext per Spring Web Application and there is also just only One ServletContext per web application. To initiate the value for both ApplicationContext and ServletContext, in web.xml, we will add something in context-param tag. That is the point that makes me confused. What are the differences between these two (i know ApplicationContext has some methods to work with beans)? and When we would use ApplicationContext and When we would use

Spring creating multiple instances of a singleton?

假装没事ソ 提交于 2019-11-29 16:58:19
问题 I have a graph of Spring beans which autowire each other. Heavily simplified illustration: <context:annotation-config/> <bean class="Foo"/> <bean class="Bar"/> <bean class="Baz"/> ... public class Foo { @Autowired Bar bar; @Autowired Baz baz; } public class Bar { @Autowired Foo foo; } public class Baz { @Autowired Foo foo; } All of these beans don't have scope specified which imply they are singletons (making them explicit singletons doesn't change anything, I've tried). The problem is that

Where can I find the example applicationContext.xml file

天大地大妈咪最大 提交于 2019-11-29 12:06:20
问题 With Spring 3 distribution there was a project folder which was packaged in the distribution . This project folder had sample applicationContext.xml file which can be used . However when I have downloaded Spring 4 distribution from here it does not come with a project folder and I am not able to find the sample applicationContext.xml . Where can I find the example applicationContext.xml file. 回答1: You can use this for further information check here. Below sample contains configuration as

Modify active profiles and refresh ApplicationContext runtime in a Spring Boot application

微笑、不失礼 提交于 2019-11-29 10:10:57
I have a Spring boot Web application. The application is configured via java classes using the @Configurable annotation. I have introduced two profiles: 'install', 'normal'. If the install profile is active, none of the Beans that require DB connection is loaded. I want to create a controller where the user can set up the db connection parameters and When it's done I want to switch the active profile from 'install' to 'normal' and refresh the application context, so the Spring can init every bean that needs DB data source. I can modify the list of active profiles from code, without problems,

configure dataSource for liquibase in spring boot

China☆狼群 提交于 2019-11-29 06:51:34
I have a spring boot application and I want to add liquibase configuration change log for it. I have created a LiquibaseConfig class for configuring liquibase: @Configuration public class LiquibaseConfiguration { @Value("${com.foo.bar.liquibase.changelog}") private String changelog; @Autowired MysqlDataSource dataSource; @Bean public SpringLiquibase liquibase() { SpringLiquibase liquibase = new SpringLiquibase(); liquibase.setDataSource(dataSource); liquibase.setChangeLog(changelog); return liquibase; } } and I have configured the datasource information in properties file: spring.datasource

Best Practise of injecting applicationContext in Spring3

社会主义新天地 提交于 2019-11-28 21:57:14
As in the title above, I am confused about pros cons between injecting applicationContext by directly @Autowired annnotation or implementing ApplicationContextAware interface in a singleton spring bean. Which one do you prefer in which cases and why? Thanks. Actually, both are bad. Both of them tie your application to the Spring framework, thus inverting the whole inversion-of-control concept. In an ideal world, your application should not be aware of being managed by an ApplicationContext at all. Once you have chosen to violate this principle, it doesn't really matter how you do it.

Spring DI applicationContext.xml how exactly is xsi:schemaLocation used?

我与影子孤独终老i 提交于 2019-11-28 18:28:17
Note: the test project I'm mentioning can be downloaded with: git clone https://github.com/mperdikeas/so-spring-di-appcontext-schemalocation.git .. and run with 'ant run'. I 'understand' that XML namespace names are just used as opaque identifiers and not meant to be used as URIs ( wikipedia ). I also 'understand' that the XML schema locations are meant to provide hints as to the actual location of schema documents and, being hints, not used in practice ( w3.org ). With that in mind I 've been experimenting with a simple Spring DI application (used in a simple J2SE setting) by modifying the

Visual Basic.NET: how to create a thread to update the UI

你说的曾经没有我的故事 提交于 2019-11-28 10:35:40
The usual VB way to handle a computationally heavy task is to put it in a background worker thread, while the main thread keeps handling the UI. Say for whatever reason I needed to do this the other way around: the main thread doing the grunt work and the background one updating the UI. Here's what I have so far. The only problem is, while the UI window (Form1) does get redrawn, you can't interact with it, not even move or resize it (the mouse cursor turns to hourglass and won't click). Public Class ProgressDisplay Private trd As Thread Public Sub New() trd = New Thread(AddressOf threadtask)