中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

做網(wǎng)站空間多大網(wǎng)站優(yōu)化包括對什么優(yōu)化

做網(wǎng)站空間多大,網(wǎng)站優(yōu)化包括對什么優(yōu)化,編程怎么學(xué),公關(guān)策劃是做什么的SpringBoot配置的文件名是固定的:application.yml application.properties YAML:以數(shù)據(jù)為中心 比Json xml更適合做配置文件 YAML語法: 1 字面量:普通值(字符串 布爾值 數(shù)字) (1) k: v (2) " "不會轉(zhuǎn)義 會轉(zhuǎn)義 2 對象,map(屬性和值) (1)…

SpringBoot配置的文件名是固定的:application.yml? application.properties

YAML:以數(shù)據(jù)為中心 比Json? xml更適合做配置文件

YAML語法:

1 字面量:普通值(字符串 布爾值 數(shù)字)

? ? ? ? (1) k: v

? ? ? ? (2) " "不會轉(zhuǎn)義? ' '會轉(zhuǎn)義

2 對象,map(屬性和值)

? ? ? ? (1) k: v??

? ? ? ? (2) 在下一行 寫對象的屬性和值

? ? 數(shù)組(List,set)

? ? ? ? 用 - 表示數(shù)組中的一個元素

? ? ? 行內(nèi)寫法

?

properties配置文件容易亂碼 需要在設(shè)置中找到這個然后調(diào)成這樣

?示例1(在yml文件中配置):

application.yaml文件中配置

Person:name: 張三age: 21boss: truebirth: 2022/12/5maps: {key1: value1,key2: value2}list: [dog,cat,pig]

Person類中利用ConfigurationProperties(prefix=" ")引入配置類中的元素 但是注意Person類中的類的名字必須與application.yaml中一致

package com.qcby.model;import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;import java.util.Date;
import java.util.List;
import java.util.Map;@Component
@ConfigurationProperties(prefix = "person")
public class Person {private String name;private Integer age;private boolean boss;private Date birth;private Map<String,String> maps;private List<String> list;public Person() {}public Person(String name, Integer age, boolean boss, Date birth, Map<String, String> maps, List<String> list) {this.name = name;this.age = age;this.boss = boss;this.birth = birth;this.maps = maps;this.list = list;}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;}public boolean isBoss() {return boss;}public void setBoss(boolean boss) {this.boss = boss;}public Date getBirth() {return birth;}public void setBirth(Date birth) {this.birth = birth;}public Map<String, String> getMaps() {return maps;}public void setMaps(Map<String, String> maps) {this.maps = maps;}public List<String> getList() {return list;}public void setList(List<String> list) {this.list = list;}@Overridepublic String toString() {return "Person{" +"name='" + name + '\'' +", age=" + age +", boss=" + boss +", birth=" + birth +", maps=" + maps +", list=" + list +'}';}
}

最終在Test包下進行測試

@RunWith(SpringRunner.class)  //聲明為測試單元
@SpringBootTest  //讀取配置
public class SpringBoot01ApplicationTests {@AutowiredPerson person;@Testpublic void Context(){System.out.println(person);}}

示例2(在properties文件中配置)

在application.properties中

person.email=lucky
person.hello=junit
person.lastName=jiangjiayi
person.age=12
person.boss=true
person.list=dog,cat
person.maps.key1=value1
person.maps.key2=value2
person.dog.name=${person.hello}  //${} 可以理解為Vue中的{{}} 調(diào)用的是上面的person.hello的值
person.dog.age=16

Person類

package com.qcby.model;import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;import javax.validation.constraints.Email;
import java.util.Date;
import java.util.List;
import java.util.Map;@Component
@ConfigurationProperties(prefix = "person")
public class Person {String email;String hello;String lastName;int age;boolean boss;List<String> list;Map<String,String>maps;Dog dog;public String getEmail() {return email;}public void setEmail(String email) {this.email = email;}public String getHello() {return hello;}public void setHello(String hello) {this.hello = hello;}public String getLastName() {return lastName;}public void setLastName(String lastName) {this.lastName = lastName;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}public boolean isBoss() {return boss;}public void setBoss(boolean boss) {this.boss = boss;}public List<String> getList() {return list;}public void setList(List<String> list) {this.list = list;}public Map<String, String> getMaps() {return maps;}public void setMaps(Map<String, String> maps) {this.maps = maps;}public Dog getDog() {return dog;}public void setDog(Dog dog) {this.dog = dog;}@Overridepublic String toString() {return "Person{" +"email='" + email + '\'' +", hello='" + hello + '\'' +", lastName='" + lastName + '\'' +", age=" + age +", boss=" + boss +", list=" + list +", maps=" + maps +", dog=" + dog +'}';}
}

Dog類

package com.qcby.model;public class Dog {String name;int age;public Dog() {}public Dog(String name, int age) {this.name = name;this.age = age;}@Overridepublic String toString() {return "Dog{" +"name='" + name + '\'' +", age=" + age +'}';}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}
}

測試類

@RunWith(SpringRunner.class)  //聲明為測試單元
@SpringBootTest  //讀取配置
public class SpringBoot01ApplicationTests {@AutowiredPerson person;@Testpublic void Context(){System.out.println(person);}}

? ?如果不是標準的application.properties 是其他的Person類中需要用PropertySource來添加配置文件的路徑

@ImportSource

導(dǎo)入Spring的配置文件,讓配置文件里面的內(nèi)容生效;Spring Boot里面沒有Spring的配置文件,我們自己編寫的配置文件,也不能自動識別;想讓Spring的配置文件生效,加載進來;@ImportResource標注在一個配置類上

SpringBoot推薦給容器中添加組件的方式;推薦使用全注解的方式
1、配置類@Configuration------>Spring配置文件
2、使用@Bean給容器中添加組件,將方法的返回值添加到容器中 容器中這個組件的默認ID就是方法名

?生成隨機數(shù):

${random.value}、${random.int}、${random.long}
${random.int(10)}、${random.int[1024,65536]}

多profile文件

? ? ? ? 通過spring:

? ? ? ? ? ? ? ? ? ? ? ? profiles:

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? active:? ? 來決定運行誰

配置文件加載位置的優(yōu)先級

–file:./config/
–file:./
–classpath:/config/
–classpath:/

優(yōu)先級由高到底,高優(yōu)先級的配置會覆蓋低優(yōu)先級的配置;?

http://www.risenshineclean.com/news/51371.html

相關(guān)文章:

  • 網(wǎng)頁設(shè)計與網(wǎng)站建設(shè)的理解link友情買賣
  • 北京做兼職從哪個網(wǎng)站許昌網(wǎng)站推廣公司
  • 網(wǎng)站策劃案怎么寫范文天津外貿(mào)seo推廣
  • 網(wǎng)絡(luò)購物網(wǎng)站大全福州seo優(yōu)化
  • 白銀市建設(shè)局網(wǎng)站王浩百度賬戶代運營
  • 做網(wǎng)站生意旁設(shè)計網(wǎng)站的公司
  • 經(jīng)營范圍里的網(wǎng)站建設(shè)網(wǎng)絡(luò)營銷策劃方案論文
  • 建材板材網(wǎng)站源碼 asp關(guān)鍵詞列表
  • 免費的制作網(wǎng)站網(wǎng)絡(luò)營銷類型
  • 網(wǎng)站開發(fā)的要注意基本原則軟文范例100例
  • 網(wǎng)絡(luò)建設(shè)與網(wǎng)站建設(shè)網(wǎng)絡(luò)營銷競價推廣
  • wordpress logo 修改精準的搜索引擎優(yōu)化
  • 廈門本地網(wǎng)站正版seo搜索引擎
  • wordpress使用指南網(wǎng)站seo最新優(yōu)化方法
  • 煙臺網(wǎng)站排名優(yōu)化公司網(wǎng)絡(luò)營銷案例分析
  • 找人做網(wǎng)站一般要多少錢免費檢測網(wǎng)站seo
  • 普通網(wǎng)站可以做商城求幾個微信推廣平臺
  • 男女怎么做那個視頻網(wǎng)站搜索引擎優(yōu)化與關(guān)鍵詞的關(guān)系
  • 個人網(wǎng)站首頁怎么做合肥推廣外包公司
  • 最牛視頻網(wǎng)站建設(shè)常州網(wǎng)絡(luò)推廣seo
  • wordpress 分類 如何修改seo搜索引擎優(yōu)化名詞解釋
  • 民宿網(wǎng)站開發(fā)方案網(wǎng)絡(luò)營銷的推廣方式
  • 建設(shè)銀行網(wǎng)上流覽網(wǎng)站做網(wǎng)站的軟件有哪些
  • 專門做學(xué)校政府的網(wǎng)站今天宣布疫情最新消息
  • 關(guān)于網(wǎng)站建設(shè)案例抖音關(guān)鍵詞推廣
  • 美食網(wǎng)站頁面設(shè)計源代碼網(wǎng)絡(luò)游戲推廣怎么做
  • 建站模板 discuz網(wǎng)絡(luò)推廣預(yù)算方案
  • 正規(guī)網(wǎng)站建設(shè)定制網(wǎng)站seo入門基礎(chǔ)教程
  • 昆明大型網(wǎng)站建設(shè)東莞網(wǎng)絡(luò)推廣及優(yōu)化
  • 網(wǎng)站設(shè)計風(fēng)格有哪幾種網(wǎng)站服務(wù)器查詢工具