Spring Boot Framework Learn important notes for preschool mastery (4)-read external resource profiles by annotation 2

Source: Internet
Author: User

The main contents of this section:

1: Thinking question: How to read multiple configuration files, what if the file does not exist

2: Configure the database connection pool

Statement:

This is the important note for the Spring boot framework to learn preschool (4)-Read the external resource Profile 2 by annotating the Edith with you learning Series-Framework Learning Spring boot Framework learning. You are welcome to comment

One: The question of thinking in the last section:

1: What if multiple profiles are written?

2: What if the configuration file configured in the value of Propertysource is not present?

Want to solve the above two questions. Let's look at the source code of @propertysource annotations first.


650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ F5773cb0f9b8264e8c113397bbdbd9b6x1003x661x29.png "alt=" f5773cb0f9b8264e8c113397bbdbd9b6x1003x66 "/>

From the above source code we can see:

1:value can be an array so, to configure multiple file profiles, simply add more than one data to the array.

The default value for 2:ignoreresourcenotfound () is false. From this method note we can see: is appropriate if the properties file is completely optional. So if the file does not exist, do not error. You can set this value to true.

Here we look at the actual combat pseudo-code:

Create a new FTP configuration file. Such as:


650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ 9b22c92683e9d0a8837c9c2c177a3346x617x593x15.png "alt=" 9b22c92683e9d0a8837c9c2c177a3346x617x593 "/>

Get the values in the FTP configuration file:


650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ E5da343a4c267d55b27147b7e9af36b1x847x280x13.png "alt=" e5da343a4c267d55b27147b7e9af36b1x847x280 "/>

Multiple value times are separated by commas.

If the file does not exist, do not error:


650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ Dc0e288681f4c5b18a1f4073ac116c04x1124x192x11.png "alt=" dc0e288681f4c5b18a1f4073ac116c04x1124x19 "/>


Two: Configure the database connection pool

First, recall how the database connection pool was configured through the XML configuration file. Such as:


650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ Adfb48f81f7601d4748786cd457d61fcx960x487x89.png "alt=" adfb48f81f7601d4748786cd457d61fcx960x487 "/>

650) this.width=650; "src=" Http://mp.sohu.com//editor/themes/default/images/spacer.gif "alt=" Spacer.gif "/> Next, Let's take a look at how to deal with annotations, such as:

650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ 0dda31d1667ccdf33fc5149c8863b319x895x711x29.png "alt=" 0dda31d1667ccdf33fc5149c8863b319x895x711 "/>

This section summarizes:

The main contents of this section:

1: Mostly know Propertysource annotation multi-configuration file how to handle

2: When the file does not exist, how to ignore.

and processing through database connection pool configuration.

In the next lesson, we're going to really get into spring boot learning.

Welcome to the Gothic public: Edith Java

Welcome to visit Edith Personal website: www.kaigejava.com

Original address of this article: Http://www.kaigejava.com/article/detail/34

Related reading:

Important annotations of Spring boot Framework Learning 3 annotation Method Read External resource profile

Spring Boot Framework Learn important annotations for preschool Mastery (2)-Configure with Java configuration spring

Spring Boot Framework Learn the important annotations of preschool mastery (1)-sprng Java configuration method


This article from the "Edith Java" blog, reproduced please contact the author!

Spring Boot Framework Learn important notes for preschool mastery (4)-read external resource profiles by annotation 2

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.