applicationcontext

Spring shutdown event that fires immediately before ApplicationContext is destroyed?

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-20 14:14:34
问题 I am looking for an interceptor or a trigger to know that, all the context beans are destroyed and the applicationcontext instance is about to destroy itself. So I can do one process at the end of the application lifetime. There is this event type ContextClosedEvent, which is close to the thing that I wanna do but, it throws the event after destruction of beans. I thing it comes with the close() method of the applicationcontext. So it doesn't fit to my need Any ideas? Regards Ali 回答1: You can

Spring shutdown event that fires immediately before ApplicationContext is destroyed?

故事扮演 提交于 2021-02-20 14:12:38
问题 I am looking for an interceptor or a trigger to know that, all the context beans are destroyed and the applicationcontext instance is about to destroy itself. So I can do one process at the end of the application lifetime. There is this event type ContextClosedEvent, which is close to the thing that I wanna do but, it throws the event after destruction of beans. I thing it comes with the close() method of the applicationcontext. So it doesn't fit to my need Any ideas? Regards Ali 回答1: You can

Spring shutdown event that fires immediately before ApplicationContext is destroyed?

不想你离开。 提交于 2021-02-20 14:03:33
问题 I am looking for an interceptor or a trigger to know that, all the context beans are destroyed and the applicationcontext instance is about to destroy itself. So I can do one process at the end of the application lifetime. There is this event type ContextClosedEvent, which is close to the thing that I wanna do but, it throws the event after destruction of beans. I thing it comes with the close() method of the applicationcontext. So it doesn't fit to my need Any ideas? Regards Ali 回答1: You can

Is it possible to cache Spring's Application Context between classes?

时光毁灭记忆、已成空白 提交于 2021-02-07 08:15:54
问题 I'm trying to improve the performance of the Spring integration tests of a project I'm working on. We're using Spring + Gradle + JUnit. With this configuration inside the build.gradle file: test { useJUnit() setForkEvery(0) setMaxParallelForks(1) } We're able to run all tests in a single JVM. Though I think this is the default behaviour. But I've been reading about Spring Test Context Caching and with this property in my application-test.yml: logging: level: org: springframework: test:

Is it possible to cache Spring's Application Context between classes?

馋奶兔 提交于 2021-02-07 08:05:34
问题 I'm trying to improve the performance of the Spring integration tests of a project I'm working on. We're using Spring + Gradle + JUnit. With this configuration inside the build.gradle file: test { useJUnit() setForkEvery(0) setMaxParallelForks(1) } We're able to run all tests in a single JVM. Though I think this is the default behaviour. But I've been reading about Spring Test Context Caching and with this property in my application-test.yml: logging: level: org: springframework: test:

Application-wide process in SpringMVC

会有一股神秘感。 提交于 2021-01-29 11:11:16
问题 Suppose I have a certain operation that should be available to every process running in Spring MVC. Say string normalization-- i need to run a method that normalizes the string fields before doing anything else on that form/data. One thing specific to do is, to normalize the String fields on every input form before they are dispatched to the back-end services. Likewise, that operation (normalization) should be run on data from the back-end before it is dispatched to the view component. One

JUnit Error: “Failed to load ApplicationContext”

喜欢而已 提交于 2020-01-24 20:14:22
问题 Nothing seems to work I'm trying to run simple test: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"/applicationContext.xml"}) @Transactional public class EmailServiceTest { I've also tried: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"src/main/webapp/WEB-INF/applicationContext.xml"}) @Transactional public class EmailServiceTest { Along with a few different things in place of "location," such as "classpath" and "file." The

Create DataSource using JBoss 7 JNDI and Spring

浪子不回头ぞ 提交于 2020-01-23 18:01:09
问题 I am first time making a webapp for Jboss server. For JBoss we have the jndi details, but I am wondering how to create the Datasource using it in spring application context. If anyone has an example to create the connection, please share it. 回答1: I will put this sample here. just to show another way to do it. <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>java:jboss/datasources/DSName</value> </property> </bean> 回答2: I found the

Spring, Failed to load ApplicationContext in tests

旧巷老猫 提交于 2020-01-16 03:53:05
问题 I have following web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd "> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class> org.springframework.web.context.request.RequestContextListener <

@ActiveProfile and spring.profiles.active

随声附和 提交于 2020-01-14 19:25:07
问题 This is a piece of my applicationContext definition to retrieve some properties. <!-- get some properties --> <context:property-placeholder ignore-resource-not-found="false" ignore-unresolvable="false" location="classpath:/properties/${spring.profiles.active:test}/some.properties"/> As you can see I letting the spring.profiles.active decide which properties will be read. My tests are annotated with: @ActiveProfile("integration") You guessed it right my spring bean profiles are actually