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

大德通众包网站建设/百度应用商店app下载安装

大德通众包网站建设,百度应用商店app下载安装,海南做网站的,推进网站建设工作计划目录: 1、操作步骤2、总结3、扩展4、第二种方法获取配置文件bean 1、操作步骤 1.新建配置文件: 2.编辑配置文件: test-serverrd-dev02.jr.rong360.com3.新建Config类: Component PropertySource(value "kirara.properti…

目录:

    • 1、操作步骤
    • 2、总结
    • 3、扩展
    • 4、第二种方法获取配置文件bean

1、操作步骤

1.新建配置文件:
在这里插入图片描述
2.编辑配置文件:

test-server=rd-dev02.jr.rong360.com

3.新建Config类:

@Component
@PropertySource(value = "kirara.properties")
public class KiraraConfig {@Value("${test-server:rd-dev02.jr.rong360.com}")private String testServer;public String getTestServer() {return testServer;}public void setTestServer(String testServer) {this.testServer = testServer;}
}

4.编辑调用类:

@RestController
public class UuapLoginController {@Autowiredprivate UuapLoginService loginService;@Autowiredprivate KiraraConfig kiraraConfig;/*** 登录方法** @param loginBody 登录信息* @return 结果*/@PostMapping("/api/v1/login")public AjaxResult login() throws Exception{AjaxResult ajax = AjaxResult.success();kiraraConfig.getTestServer();return ajax;}
}

2、总结

主要是用Config类去加载配置文件内容,然后注入到类中进行使用。

3、扩展

Spring中加载ApplicationContext.xml的方法分享,如下所示:

spring 中加载xml配置文件的方式 有4种,分别为:
XmlBeanFactory,
ClassPathXmlApplicationContext,
FileSystemXmlApplicationContext,
XmlWebApplicationContext

扩展详情

4、第二种方法获取配置文件bean

1.配置实体类:

/*** 学生实体类* Created by ASUS on 2018/5/4*/@Component("Student")
public class Student {private String name;private  int 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;}public Student(String name, int age) {this.name = name;this.age = age;}public Student() {}@Overridepublic String toString() {return "Student{" +"name='" + name + '\'' +", age=" + age +'}';}
}

2.启动类配置:

/*** springboot启动类**/@SpringBootApplication
//读取resources目录下的applicationContext.xml
@ImportResource("classpath:applicationContext.xml")
public class Application
{public static void main( String[] args ){ApplicationContext applicationContext= SpringApplication.run(Application.class,args);Student student= (Student) applicationContext.getBean("student",Student.class);System.out.println("message:"+student.toString());}}

3.application.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" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-4.0.xsd  "><bean name="student" class="springboot.entity.Student"><property name="name" value="小黄"/><property name="age" value="19"/></bean></beans>

4.测试结果:
在这里插入图片描述

http://www.jmfq.cn/news/4960009.html

相关文章:

  • 卖号的正规交易平台/北京seo优化推广
  • wordpress搜索翻页404/win10优化大师是官方的吗
  • 国际电商怎么做/谷歌seo推广服务
  • 个人网站怎么建/青岛排名推广
  • 网站优化应该怎么做/百度竞价怎么收费
  • 网站哪些功能是PHP做的/怎样做一个网页
  • 网站配色 标记色/一手app推广接单平台
  • 公司网站管理制度/搜索引擎优化的主要内容
  • 如何做网站源码/常州网站建设书生商友
  • 上海做网站最专业/网站设计制作公司
  • 昆明做网站建设的公司/奉化首页的关键词优化
  • 网站首页英文/灰色关键词快速排名
  • 郑网站建设/cps推广接单平台
  • 建筑工程网正保/宁波seo行者seo09
  • 丽水网站建设专业的公司/search搜索引擎
  • 网站服务器租用注意事项/加拿大搜索引擎
  • 网站建设员工技能要求/百度竞价推广点击软件奔奔
  • 泰州网站制作哪家好/百度竞价排名查询
  • 手机做任务网站/网络seo关键词优化技巧
  • 厦门网站设计定制/百度竞价是seo还是sem
  • 石湾做网站公司/怎么做网络营销平台
  • b2b哪个免费网站好/seo外包公司怎么样
  • 微网站免费制作/seo长沙
  • wordpress知名博客主体/网络推广优化工具
  • 微信公众平台 网站 对接/长沙优化网站哪家公司好
  • phpcms v9网站建设入门/大亚湾发布
  • 券商 做网站/我们seo
  • 网站备案 多少钱/会计培训班的费用是多少
  • 自己做社交网站/百度发广告需要多少钱
  • 网站备案号查询网址/西安网络推广公司大全