国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁(yè) > news >正文

做網(wǎng)站大概需要多少錢(qián)深圳最新疫情

做網(wǎng)站大概需要多少錢(qián),深圳最新疫情,自助網(wǎng)站建設(shè)程序,網(wǎng)站建設(shè)實(shí)習(xí)日記目錄 1. 使用Value和ConfigurationProperties2. 使用PropertySource創(chuàng)建Person.java寫(xiě)一個(gè)測(cè)試類(lèi) 3. 使用ImportResourceStudent類(lèi)創(chuàng)建beans.xml在主類(lèi)中引入測(cè)試 其他心得 1. 使用Value和ConfigurationProperties 這里不加贅述了,前面我也發(fā)過(guò),這里就放…

目錄

  • 1. 使用@Value和@ConfigurationProperties
  • 2. 使用@PropertySource
      • 創(chuàng)建Person.java
      • 寫(xiě)一個(gè)測(cè)試類(lèi)
  • 3. 使用@ImportResource
    • Student類(lèi)
    • 創(chuàng)建beans.xml
    • 在主類(lèi)中引入
    • 測(cè)試
  • 其他
  • 心得

1. 使用@Value和@ConfigurationProperties

這里不加贅述了,前面我也發(fā)過(guò),這里就放個(gè)鏈接吧
@Value獲取值和@ConfigurationProperties獲取值用法及比較(springboot)

2. 使用@PropertySource

創(chuàng)建Person.java

package com.example.springbootdaily2.model;import org.springframework.format.annotation.DateTimeFormat;import java.util.Date;
import java.util.List;
import java.util.Map;@Component
@PropertySource(value = "classpath:person.properties")
// 這個(gè)是前綴的意思
@ConfigurationProperties(prefix = "person2")
public class PersonX {private String name;private Character sex;@DateTimeFormat(pattern = "YYYY-MM-SS")private Date birthday;private Integer age;private String address;private Map<String, Integer> maps;private List<String> lists;private Dog dog;public String getName() {return name;}public void setName(String name) {this.name = name;}public Character getSex() {return sex;}public void setSex(Character sex) {this.sex = sex;}public Date getBirthday() {return birthday;}public void setBirthday(Date birthday) {this.birthday = birthday;}public String getAddress() {return address;}public void setAddress(String address) {this.address = address;}public Dog getDog() {return dog;}public void setDog(Dog dog) {this.dog = dog;}public Integer getAge() {return age;}public void setAge(Integer age) {this.age = age;}public Map<String, Integer> getMaps() {return maps;}public void setMaps(Map<String, Integer> maps) {this.maps = maps;}public List<String> getLists() {return lists;}public void setLists(List<String> lists) {this.lists = lists;}@Overridepublic String toString() {return "Person{" +"name='" + name + '\'' +", sex=" + sex +", birthday=" + birthday +", age=" + age +", address='" + address + '\'' +", maps=" + maps +", lists=" + lists +", dog=" + dog +'}';}
}

創(chuàng)建person.properties

person2.name="李四"
person2.sex=男
person2.birthday=2022-02-07
person2.age=18
person2.maps.keys1=16
person2.maps.keys2=16
person2.lists=[12,24,57]
person2.address="保定廉恥"
person2.dog.name=${random.value}

寫(xiě)一個(gè)測(cè)試類(lèi)

package com.example.springbootdaily;
import com.example.springbootdaily.model.Dog;
import com.example.springbootdaily.model.Person;
import com.example.springbootdaily.model.Person2;
import com.example.springbootdaily.model.PersonX;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringTest {@AutowiredPersonX personX;@Testpublic void print4(){System.out.println(personX);}
}

輸出結(jié)果:

Person{name='"岳軒子"', sex=M, 
birthday=Sun Dec 26 00:00:00 CST 2021, age=18, 
address='"保定武漢"', maps={keys2=16, keys1=16}, lists=[[12, 24, 57]], 
dog=Dog{name='cdab390f55c9f8a6bbb420cd15607add'}}

注:如果顯示亂碼,設(shè)置文件編碼為utf-8
在這里插入圖片描述

3. 使用@ImportResource

Student類(lèi)

package com.example.springbootdaily.model;public class Student {private String name;private Integer age;public String getName() {return name;}public void setName(String name) {this.name = name;}public Integer getAge() {return age;}public void setAge(Integer age) {this.age = age;}@Overridepublic String toString() {return "Student{" +"name='" + name + '\'' +", age=" + age +'}';}
}

創(chuàng)建beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><bean id="student" class="com.example.springbootdaily.model.Student"><property name="name" value="李四"/><property name="age" value="18"/></bean>
</beans>

在主類(lèi)中引入

package com.example.springbootdaily;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;@SpringBootApplication
@ImportResource(locations = "classpath:beans.xml")
public class SpringbootDailyApplication {public static void main(String[] args) {SpringApplication.run(SpringbootDailyApplication.class, args);}}

測(cè)試

package com.example.springbootdaily;import com.example.springbootdaily.model.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringTest {@AutowiredStudent student;@Testpublic void print5(){System.out.println(student);}
}

運(yùn)行結(jié)果:

Student{name='李四', age=18}

其他

我們可以導(dǎo)入配置文件處理器,以后編寫(xiě)配置就有提示了
<!‐‐導(dǎo)入配置文件處理器,配置文件進(jìn)行綁定就會(huì)有提示‐‐>
依賴(lài):

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring‐boot‐configuration‐processor</artifactId><optional>true</optional>
</dependency>

心得

平常還是要多多總結(jié)的。
在這里插入圖片描述
謝謝大家支持!!!!

http://aloenet.com.cn/news/33922.html

相關(guān)文章:

  • 濟(jì)南科技市場(chǎng)做網(wǎng)站河南做網(wǎng)站優(yōu)化
  • 做h5哪些網(wǎng)站好 知乎百度小程序
  • 蕪湖企業(yè)做網(wǎng)站電商運(yùn)營(yíng)入門(mén)基礎(chǔ)知識(shí)
  • 個(gè)人網(wǎng)站好備案嗎東莞seo網(wǎng)站排名優(yōu)化
  • Linux做視頻網(wǎng)站網(wǎng)速均衡今日最新足球推薦
  • 互聯(lián)網(wǎng)app網(wǎng)站建設(shè)方案模板下載霸榜seo
  • 毛絨玩具 東莞網(wǎng)站建設(shè) 技術(shù)支持江西短視頻seo搜索報(bào)價(jià)
  • 莫鄰網(wǎng)站在線客服系統(tǒng)3步打造seo推廣方案
  • 哪些網(wǎng)站做的比較炫網(wǎng)頁(yè)設(shè)計(jì)個(gè)人主頁(yè)
  • 百度網(wǎng)盤(pán)可以做網(wǎng)站嗎英文網(wǎng)站設(shè)計(jì)公司
  • 如何評(píng)價(jià)小米的網(wǎng)站建設(shè)小程序開(kāi)發(fā)平臺(tái)官網(wǎng)
  • 網(wǎng)站做302重定向網(wǎng)絡(luò)營(yíng)銷(xiāo)的未來(lái)發(fā)展趨勢(shì)
  • 國(guó)外網(wǎng)站代理如何查詢(xún)網(wǎng)站收錄情況
  • 頁(yè)面設(shè)計(jì)在線seo搜狗
  • 網(wǎng)絡(luò)培訓(xùn)班靠譜嗎網(wǎng)站優(yōu)化哪家好
  • 網(wǎng)站建設(shè)的售后seo優(yōu)化服務(wù)是什么
  • 日本軟銀集團(tuán)市值關(guān)鍵詞優(yōu)化公司排行
  • 做淘寶貨源網(wǎng)站seo關(guān)鍵詞優(yōu)化排名軟件
  • 網(wǎng)站的開(kāi)發(fā)方法谷歌全球營(yíng)銷(xiāo)
  • 定制做網(wǎng)站費(fèi)用seo還有哪些方面的優(yōu)化
  • 做靜態(tài)網(wǎng)站的開(kāi)題報(bào)告百度電話怎么轉(zhuǎn)人工客服
  • 貴港網(wǎng)站建設(shè)公司seo外包公司興田德潤(rùn)
  • 黔江網(wǎng)站建設(shè)推廣軟件賺錢(qián)的平臺(tái)
  • 自貢做網(wǎng)站的公司深圳在線制作網(wǎng)站
  • 橋頭仿做網(wǎng)站搜索引擎營(yíng)銷(xiāo)方案例子
  • 廣州市手機(jī)網(wǎng)站建設(shè)企業(yè)專(zhuān)業(yè)搜索引擎優(yōu)化
  • html5 個(gè)人網(wǎng)站模板世界足球排名
  • 深圳做響應(yīng)式網(wǎng)站公司優(yōu)優(yōu)群排名優(yōu)化軟件
  • 做網(wǎng)站一天賺多少錢(qián)seo崗位有哪些
  • 北京建網(wǎng)站實(shí)力公司app線上推廣是什么工作