本文整理汇总了Java中org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean.setIpAddress方法的典型用法代码示例。如果您正苦于以下问题:Java EurekaInstanceConfigBean.setIpAddress方法的具体用法?Java EurekaInstanceConfigBean.setIpAddress怎么用?Java EurekaInstanceConfigBean.setIpAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean
的用法示例。
在下文中一共展示了EurekaInstanceConfigBean.setIpAddress方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入方法依赖的package包/类
@Before
public void setup() {
eurekaHttpClient = new RestTemplateTransportClientFactory()
.newClient(new DefaultEndpoint(serviceUrl));
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
String appname = "customapp";
config.setIpAddress("127.0.0.1");
config.setHostname("localhost");
config.setAppname(appname);
config.setVirtualHostName(appname);
config.setSecureVirtualHostName(appname);
config.setNonSecurePort(4444);
config.setSecurePort(8443);
config.setInstanceId("127.0.0.1:customapp:4444");
info = new EurekaConfigBasedInstanceInfoProvider(config).get();
}
示例2: register
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入方法依赖的package包/类
@RequestMapping(path = "/register", method = POST)
public String register() {
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
String appname = "customapp";
config.setIpAddress("127.0.0.1");
config.setHostname("localhost");
config.setAppname(appname);
config.setVirtualHostName(appname);
config.setSecureVirtualHostName(appname);
config.setNonSecurePort(4444);
config.setInstanceId("127.0.0.1:customapp:4444");
this.registration = EurekaRegistration.builder(config)
.with(this.clientConfig, this.context)
.build();
this.serviceRegistry.register(this.registration);
return config.getInstanceId();
}
示例3: 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;
}
示例4: 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;
}