Those annotations in the "@ContextConfiguration" Java World

Source: Internet
Author: User

Use annotations to introduce multiple configuration files when @ContextConfiguration spring consolidates JUNIT4 tests

@ContextConfiguration (Locations= ".. /applicationcontext.xml ") = simpleconfiguration. class = {"Classpath*:/spring1.xml", "Classpath*:/spring2.xml"})

The purpose of @EnableAutoConfigurationannotation is to have spring Boot automatically configure the spring framework based on the dependencies declared by the application, which reduces the developer's workload. The annotations "@RestController" and "@RequestMapping" are provided by Spring MVC to create a REST service. These two annotations are not related to Spring Boot itself.

You only need to add "@EnableAutoConfiguration" annotations on the master configuration Java class to enable automatic configuration. Spring Boot's Auto-configuration feature is not intrusive, just as a basic default implementation. Developers can override the functionality provided by automatic configuration by defining other beans. For example, when the application has its own data source bean defined, the HSQLDB provided by the automatic configuration will not take effect. This gives developers a lot of flexibility. You can quickly create a prototype application that can be run immediately, and can be constantly modified and adapted to suit the needs of application development at different stages. Perhaps at the beginning of the application, the embedded memory database (such as HSQLDB) is sufficient, and later in the need to replace the MySQL database. Spring Boot makes such a switch easy.

Those annotations in the "@ContextConfiguration" Java World

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.