applicationcontext

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

帅比萌擦擦* 提交于 2019-12-18 05:55:53
问题 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

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

泄露秘密 提交于 2019-12-17 19:59:16
问题 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).

Reload or refresh a Spring application context inside a test method?

旧时模样 提交于 2019-12-17 16:11:24
问题 I need to change the Spring profiles that are active in my applicationContext within a single method of my test class, and to do so I need to run one line of code before refreshing the contest because I am using a ProfileResolver. I have tried the following: @WebAppConfiguration @ContextConfiguration(locations = {"/web/WEB-INF/spring.xml"}) @ActiveProfiles(resolver = BaseActiveProfilesResolverTest.class) public class ControllerTest extends AbstractTestNGSpringContextTests { @Test public void

Get application context returns null

那年仲夏 提交于 2019-12-17 05:04:54
问题 The following schema has been touted as the way to get application context from anywhere within my android app. But sometimes doing MyApp.getContext() returns null. I tried changing the schema by removing static from getContext() so that I would do MyApp.getInstance().getContext() . It still returns null. How do I fix this? How do I get my application's context from anywhere within my app? public class MyApp extends Application { private static MyApp instance; public static MyApp getInstance(

Spring transactional context doesn't persist data

醉酒当歌 提交于 2019-12-13 12:27:24
问题 I know that my problem is a common problem, but I've checked a lot of questions here, checked Spring documentation and I really don't know what I am doing wrong. My problem: I've got a Spring WebFlow project using JPA (implementation: OpenJPA + MySQL database). I use Spring ORM to inject EntityManager (by @PersistenceContext annotation) to my simple RegisterDAO. I have configured GlassFishs (which I am using) connection pools for using MySQL and everything works - I can work with my database,

I have WEB-INF/applicationContext.xml but application cannot find it

[亡魂溺海] 提交于 2019-12-12 20:02:41
问题 I uninstalled MyEclipse4S and reinstalled it and run project from workspace and started getting following exception. I do have /WEB-INF/applicationContext.xml at the right place :( my context files are at bottom. org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]

Using ApplicationContext in Spring MVC.

江枫思渺然 提交于 2019-12-12 13:09:05
问题 I have a spring.xml file where in all the bean definitions are listed, where i have listed all the dependencies using beans, specified messageSource, dataSource etc. Also i have a class ApplicationContext class where iam using the context to get all the beans. The code is :: package models; import org.springframework.context.ApplicationContext; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;

Spring: Properly setup @ComponentScan

為{幸葍}努か 提交于 2019-12-12 10:48:33
问题 I have following set up for my Spring Application Context . @Configuration public class RmiContext { @Bean public RmiProxyFactoryBean service() { RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean(); rmiProxy.setServiceUrl("rmi://127.0.1.1:1099/Service"); rmiProxy.setServiceInterface(Service.class); return rmiProxy; } } @Configuration public class LocalContext { @Bean public Controller Controller() { return new ControllerImpl(); } } @Configuration @Import({RmiContext.class, LocalContext

Spring contexts hierarchy

十年热恋 提交于 2019-12-12 07:54:16
问题 I'm going to create several Spring contexts with one parent context. Here is how I'm going to create parent context: new ClassPathXmlApplicationContext(new String[] {"ApplicationContext/application.xml"}) And each parent context I want to create in following way: PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); configurer.setProperties(properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(appContext); context

load applicationContext in Java web project (Not MVC)

北城以北 提交于 2019-12-12 03:38:32
问题 Fairly new to Spring, in stand alone applications,i have seen the following: ApplicationContext context = new ClassPathXmlApplicationContext( "SpringBeans.xml"); But in web application i have not seen this approach of creating using a new keyword. How do we achieve the same in Web app ? 来源: https://stackoverflow.com/questions/42725862/load-applicationcontext-in-java-web-project-not-mvc