当前位置: 首页 > 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/14320995/

相关文章:

  • 成都网站系统开发高端品牌男鞋
  • 做爰直播网站最好的网站建设团队
  • 网站开发报价pptphp网站端口
  • 凡科网网站怎么设置会员登录板块yahoo引擎入口
  • 销售网站需要备案么做网站在
  • 类网站建设什么是网络推广方案
  • wordpress怎么恢复自带主题广州网站营销优化开发
  • 企业网站建设需求调查怎么用ps做网站首页图片尺寸
  • 响应式门户网站模板简述电子政务网站设计的技术
  • 织梦制作html 网站地图wordpress 照片墙 插件
  • 网站建设教程 湖南岚鸿网站建设策划包括哪些内容
  • 网站开发为什么需要域名哈尔滨建设网站的免费咨询
  • 网站备案查询怎么查原创网站源码
  • 永康建设局网站WordPress菜单调用不出
  • 网站开发一般用什么工具成都专业网站推广
  • 东莞做门户网站郑州最好的品牌策划公司
  • 多个域名绑定同一网站吗承德企业网站建设
  • 昆明广告网站制作网站建设"淘宝网" 在颜色选取和搭配方面有哪些值得学习的地方.
  • 广东网站建设价格济南国画网站济南网站建设公司
  • 如何搭建网站的支付接口知名品牌logo标志设计解析
  • 西安做网站南通公司邯郸专业网站建设公司
  • 网站的验证码是怎么做的建设响应式网站有哪些好处
  • 郑州建站公司网站o2o网站开发方案
  • 8月4号建设部网站国内5大搜索引擎
  • 培训的网站建设网站建设嘉兴
  • 在线设计发型seo是什么意思中文
  • 临汾市建设局网站WordPress破解版主题
  • 长沙网站seo推广公司成都装修设计公司网站
  • 北京专业网站建设网站推广小程序商店怎么弄
  • 可信网站认证代理网站如何做外链教程视频