当前位置: 首页 > news >正文

上海网站建设公司指南域名网站排名

上海网站建设公司指南,域名网站排名,网址导航大全软件下载,在哪里买空间做网站目录 1. 使用Value和ConfigurationProperties2. 使用PropertySource创建Person.java写一个测试类 3. 使用ImportResourceStudent类创建beans.xml在主类中引入测试 其他心得 1. 使用Value和ConfigurationProperties 这里不加赘述了#xff0c;前面我也发过#xff0c;这里就放… 目录 1. 使用Value和ConfigurationProperties2. 使用PropertySource创建Person.java写一个测试类 3. 使用ImportResourceStudent类创建beans.xml在主类中引入测试 其他心得 1. 使用Value和ConfigurationProperties 这里不加赘述了前面我也发过这里就放个链接吧 Value获取值和ConfigurationProperties获取值用法及比较springboot 2. 使用PropertySource 创建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) // 这个是前缀的意思 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 MapString, Integer maps;private ListString 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 MapString, Integer getMaps() {return maps;}public void setMaps(MapString, Integer maps) {this.maps maps;}public ListString getLists() {return lists;}public void setLists(ListString 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 };} } 创建person.properties person2.name李四 person2.sex男 person2.birthday2022-02-07 person2.age18 person2.maps.keys116 person2.maps.keys216 person2.lists[12,24,57] person2.address保定廉耻 person2.dog.name${random.value}写一个测试类 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);} } 输出结果 Person{name岳轩子, sexM, birthdaySun Dec 26 00:00:00 CST 2021, age18, address保定武汉, maps{keys216, keys116}, lists[[12, 24, 57]], dogDog{namecdab390f55c9f8a6bbb420cd15607add}}注如果显示乱码设置文件编码为utf-8 3. 使用ImportResource Student类 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 };} } 创建beans.xml ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdbean idstudent classcom.example.springbootdaily.model.Studentproperty namename value李四/property nameage value18//bean /beans在主类中引入 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);}} 测试 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);} } 运行结果 Student{name李四, age18}其他 我们可以导入配置文件处理器以后编写配置就有提示了 !‐‐导入配置文件处理器配置文件进行绑定就会有提示‐‐ 依赖 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring‐boot‐configuration‐processor/artifactIdoptionaltrue/optional /dependency心得 平常还是要多多总结的。 谢谢大家支持
http://www.hkea.cn/news/14514882/

相关文章:

  • 全国网站建设汇编小程序app分销网站建设
  • 网站制作小工具淘宝美工做倒计时图片网站
  • 什么是网站维护中wordpress最好选择
  • 沈阳市建设监理协会网站做网站的标题图片
  • 做美食网站首页怎么做原有网站已备案 怎么做接入
  • 高端网站哪种好做自媒体可以搬运国外网站新闻吗
  • 网站建设站长学做网站最好的网站
  • 手机网站建设设计公司网页设计师就业趋势
  • 常州网站排名提升wordpress 营销模板下载
  • 电子政务门户网站建设公司小程序怎么制作
  • 有电脑网站怎么做手机网站蓬莱做网站那家好
  • 视频网站开发周期网络营销推广方式包括?
  • 广州网站优化工具科技创新的重要性和意义
  • 目前搜索引擎排名wordpress优化 春哥
  • 中国第一个做电商网站开发网站需要怎么做
  • 关于申请网站建设维护经费校际凡科平台怎么登录
  • 媒体网站网页设计用vs做的网站怎么打开
  • 浅析小型企业网站的建设太康县城乡建设局规划网站
  • 建设网站搞网络营销的总结wordpress+search+sql
  • 网站模板套餐男女做视频观看网站
  • 营销网站的建造步骤短代码 wordpress
  • 建设二手商品网站总结建设网站有什么网站
  • 南宁市建设工程质量监督站网站怎么弄网址
  • 网站建设方案设计公司网站免费自建
  • 手机网站生产app华泰保险公司官方网站电话
  • 帝国网站系统做专题四川西充县建设局网站
  • 网站1996年推广本网站只做信息展示
  • 阿里巴巴怎么建设网站网站制作设计收费标准
  • 网站风格对比信息表网站建设哪家好知道万维科技
  • python做网站好吗做网站怎么选取关键词