apollo参数信息

springboot整合Apollo

在pom.xml中添加依赖包

		<dependency>
			<groupId>com.ctrip.framework.apollo</groupId>
			<artifactId>apollo-client</artifactId>
			<version>1.5.1</version>
		</dependency>

修改application.yml以apollo配置参数启动

springboot整合Apollo

apollo参数配置信息

#******apollo参数配置******#
app:
  id: jf-tk-mybatis-1.0
apollo:
  meta: http://localhost:8080
  bootstrap:
    enabled: true
    eagerLoad:
      enabled: true

springboot整合Apollo

在springboot启动类开启Apollo配置,添加注解 @EnableApolloConfig

springboot整合Apollo

创建controller测试Apollo

package com.jeff.tk.mybatis.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloWordController {
	
	@Value("${server.port}")
    private String port;
    
    @RequestMapping("hello")
    public String hello() {
        
        return "HelloWord";
    }
    
    @RequestMapping("getPort")
    public String getPort() {
        
        return port;
    }

}

http://localhost:9002/getPort

springboot整合Apollo

相关文章:

  • 2021-11-21
  • 2021-07-26
  • 2021-10-01
  • 2021-08-02
  • 2021-12-09
  • 2021-11-30
  • 2021-12-12
  • 2021-09-03
猜你喜欢
  • 2022-01-01
  • 2021-06-01
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
相关资源
相似解决方案