applicationcontext

Enabling UTF-8 character set in JSF2.0, Hibernate, MySQL

瘦欲@ 提交于 2019-12-05 08:48:58
We are to enable UTF-8 character encoding to our web application designed using JSF2.0, Hibernate, MySQL. Following is the datasource defined in our application context file <bean id="DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="com.mysql.jdbc.Driver" /> <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/dbname" /> <property name="maxPoolSize" value="10" /> <property name="maxStatements" value="0" /> <property name="minPoolSize" value="5" /> <property name="useUnicode" value="yes" /> <property name=

Loading applicationcontext.xml when using SpringApplication

最后都变了- 提交于 2019-12-05 03:30:12
Could anyone provide an example of a SpringApplication that loads an applicationContext.xml file? I'm attempting to move my GWT RPC application to a RESTful web service by using a Spring's Example (Gradle based). I have an applicationContext.xml but I do not see how to get SpringApplication to load it. Loading manually via ApplicationContext context = new ClassPathXmlApplicationContext(args); results in an empty context. ...and even if that worked it would be separate from the one returned from SpringApplication.run(Application.class, args); Or is there a way to get external beans into the app

Create a spring boot application with multiple child contexts

倾然丶 夕夏残阳落幕 提交于 2019-12-04 23:49:45
I'm trying to create an application using spring boot with an hierarchical application context. My current main method looks like: public static void main(String[] args) { new SpringApplicationBuilder(TestApplication.class) .child(AuditServiceConfiguration.class).web(true) .child(TaskServiceConfiguration.class).web(true) .run(args); } and the two children configurations are annotated with: @EnableAutoConfiguration @Configuration The idea is to have a parent context containing all common beans and each child context to run its own MVC while being isolated from its siblings. Unfortunately when I

Spring ApplicationListener for ContextRefreshEvent. How to invoke only once per Hierarchy?

回眸只為那壹抹淺笑 提交于 2019-12-04 11:38:54
I need to execute a certain procedure once my spring web application starts all of its beans. For this I created a ApplicationListener<ContextRefreshedEvent> . However, when I run the application it gets called several times (as we have contexts for different namespaces e.g. mvc-servlets, etc.) but I need this particular listener to be called only once and when all the context where properly initialized. Is there a way to achieve what I'm trying to do? I'm using spring 3.1.0.RELEASE. Yes, there is a way but it can be a bit tricky. The child contexts you are talking about are probably contexts

Spring ApplicationContext.getBean(Class c) not working for proxy classes

[亡魂溺海] 提交于 2019-12-04 11:08:03
问题 I need to look up beans via their class type. When the beans have been wrapped by a Proxy (some methods are @Transactional) - the ApplicatoinContext fails to find them. I find that if I look them up via an interface, it works but in this case I'm working with a concrete class type. I know the bean is of the type I'm looking for but the getBean() method fails. I can debug (and fix) the problem in Spring's AbstractBeanFactory code. The issue is that it checks the type of the beanInstance

How to pass local filename to ClassPathXmlApplicationContext?

耗尽温柔 提交于 2019-12-04 09:52:04
By "local filename" I mean that resource file is located in the same directory as class file. In the case below this is JUnitRunner.class file. Java's getResource() file can handle this if path does not start with / ' I can't figure out, how to do the same ClassPathXmlApplicationContext constructor? package springtests; import java.io.File; import java.net.URISyntaxException; import java.net.URL; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.support.ClassPathXmlApplicationContext; public class JUnitRunner { private final

Object Sharing Between Activities in Android

为君一笑 提交于 2019-12-04 06:54:14
Hi I have a question about passing an object throughout the app. Say I want to have a big custom object throughout the app. This object will be used by multiple activities and services. What I did at first is this. First, I created an Application class and define a singleton object. public class FooApplication extends Application { public static SharedObj obj; ... } Second, in an activity I set a value of this object public class FooActivity extends Activity { OnCreate() { FooApplication.obj = SharedObj.getInstance(); } } Third, in another activity I access this object public class BarActivity

@Autowired is not working with jersey and spring

你。 提交于 2019-12-04 05:48:18
问题 When I am running test at that time @Autowired is working but when I run the web app and try to fetch data at that time its throwing null pointer exception. this is my controller In this BuyerRepo is always null import com.retail.exception.InvalidIdException; import com.retail.model.Buyer; import com.retail.repository.BuyerRepo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.ws.rs.GET; import javax.ws.rs.Path;

JUnit custom runner with Spring application context

泪湿孤枕 提交于 2019-12-04 03:57:22
I am fairly new to Spring and am working with a suite of JUnit 4.7 integration tests for a web application. I have a number of working test cases of the form: import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/META-INF/spring/testContext.xml" }) public class myTest { @Test public void testCreate() { //execute tests .... } } My application has a number of external dependencies that

Unable to Import persistence.xml within applicationContext.xml file

一个人想着一个人 提交于 2019-12-04 02:21:48
问题 I'm using eclipse juno IDE I have Java application which have src folder. within the folder I have: 1) applicationContext.xml 2) persistence.xml I also have DBInterface and i implemented it with JPA. Now in the applicationContext.xml file I have a bean for the JPA implemention. When I tried to inject the bean i got an excpetion that said something like "No Persistence Provider was found". So I tried to import the persistence file within the applicationContext file but i'm getting another