本文整理汇总了Java中org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean.setHealthCheckUrl方法的典型用法代码示例。如果您正苦于以下问题:Java EurekaInstanceConfigBean.setHealthCheckUrl方法的具体用法?Java EurekaInstanceConfigBean.setHealthCheckUrl怎么用?Java EurekaInstanceConfigBean.setHealthCheckUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean
的用法示例。
在下文中一共展示了EurekaInstanceConfigBean.setHealthCheckUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: eurekaInstanceConfig
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入方法依赖的package包/类
@Bean
/**
* Dynamically assign the hosts IP address to this instances of the Eureka Client
*
* @param inetUtils Java Networks Utilities
* @return An instance of a EurekaInstanceConfigBean with dynamically configured IP address
*/
public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils){
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
String ip = null;
String urlPattern = "http://{0}:{1}{2}";
try {
// Get the IP address of the current host using Java Network Utils
ip = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
e.printStackTrace();
}
config.setIpAddress(ip);
config.setPreferIpAddress(true);
// Build the Status Page URL specific to this instances IP Address
String statusPageUrl = MessageFormat.format(urlPattern,
config.getIpAddress(),
port,
config.getStatusPageUrlPath());
config.setStatusPageUrl(statusPageUrl);
// Build the Health Page URL specific to this instances IP Address
String healthPageUrl = MessageFormat.format(urlPattern,
config.getIpAddress(),
port,
config.getHealthCheckUrlPath());
config.setHealthCheckUrl(healthPageUrl);
return config;
}
示例2: eurekaInstanceConfigBean
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入方法依赖的package包/类
@Bean
public EurekaInstanceConfigBean eurekaInstanceConfigBean() {
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
String springAppName = this.env.getProperty("spring.application.name", "");
int port = this.sidecarProperties.getPort();
config.setNonSecurePort(port);
config.setInstanceId(getDefaultInstanceId(this.env));
if (StringUtils.hasText(springAppName)) {
config.setAppname(springAppName);
config.setVirtualHostName(springAppName);
config.setSecureVirtualHostName(springAppName);
}
String hostname = this.sidecarProperties.getHostname();
String ipAddress = this.sidecarProperties.getIpAddress();
if (!StringUtils.hasText(hostname) && StringUtils.hasText(this.hostname)) {
hostname = this.hostname;
}
if (StringUtils.hasText(hostname)) {
config.setHostname(hostname);
}
if (StringUtils.hasText(ipAddress)) {
config.setIpAddress(ipAddress);
}
String scheme = config.getSecurePortEnabled() ? "https" : "http";
config.setStatusPageUrl(scheme + "://" + config.getHostname() + ":"
+ this.managementPort + config.getStatusPageUrlPath());
config.setHealthCheckUrl(scheme + "://" + config.getHostname() + ":"
+ this.managementPort + config.getHealthCheckUrlPath());
config.setHomePageUrl(scheme + "://" + config.getHostname() + ":" + port
+ config.getHomePageUrlPath());
return config;
}