5

I have a project based on Spring Framework 4 and its subproject - Spring Data Solr.

All examples I had a chance to see explain how to organize your project - from base entity ( pojo's ) classes till spring specific classes such as repositories and service. When it came to test functionality all examples show a test with private field ( spring bean ) which usually becomes initialized with the help of annotation

@ContextConfiguration(classes = some-spring-data-main-class.class, loader = SpringApplicationContextLoader.class)

Then it is possible to call for it's bean's methods in @Test methods.

But, when it comes to init bean in a project - how to make it with Spring 4, which is completely XMLless ( I mean, I do not have an applicationContext xml file ).

P.S. in Spring 3 we usually wrote smth like:

ApplicationContext context = new ClasspathApplicationContext("applicationContext.xml") 

Is it reasonable to expect smth similar to this of Spring 4 introduces absolutely new concepts of application initialization? What should we write now to init app's first bean?

1 Answer 1

4

I got it !

In Spring 4 now we have to write:

ApplicationContext context = new AnnotationConfigApplicationContext(<out-main-config-class>.class);

and then call for beans and its methods.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.