103天
行百里者半九十,想要在一个行业里成为顶尖人才,一定满足一万小时定律,要想学好JAVA,需要持之以恒不断地努力,每天都要勤思考+善于询问+解决问题!
知识温故而知新>>>>>>
虚拟机网络配置
自定义网络IP, 网关,DNS
命令:vim /etc/sysconfig/network-scripts/ifcfg-eth0,进入编辑
注意:BOOTPROTO=none,调整为手动设置,配置才能生
对于刚安装完的虚拟机,添加如下设置效
IPADDR=192.168.1.3
NETMASK=255.255.255.0
GATEWAY=192.168.1.2
DNS1=8.8.8.8
然后重启网络服务:service network restart
ifcfg-eht0(示例)
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
NAME=eht0
UUID=726ff039-063c-4662-a654-28b791d99a24
ONBOOT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=yes
IPADDR=10.100.105.10
PREFIX=24
GATEWAY=10.100.105.1
DNS1=202.196.64.1
MTU=2
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
LAST_CONNECT=1575340376
校园网锐捷客户端下配置虚拟机网络
查看真实主机的网络信息
image.pngimage.png
记住IP地址,网关,子网掩码和DNS等信息
设置虚拟机上网方式为桥接
3.png进入Linux下配置网络信息
1.png2.png
PING一下主机与虚拟机是不是互联互通(校园网状态下,虚拟机不能访问外网)
4.png5.png
今天学到的知识>>>>>>
EurekaApplication
package com.bjsxt;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.web.bind.annotation.RequestMapping;
@EnableEurekaServer
@SpringBootApplication
public class EurekaApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
}
application-eureka1.properties
spring.application.name=eureka-server
server.port=8761
#设置eureka实例名称,与配置文件的变量为主
eureka.instance.hostname=eureka1
#设置服务注册中心地址,指向另一个注册中心
eureka.client.serviceUrl.defaultZone=http://eureka2:8761/eureka/
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
application-eureka2.properties
spring.application.name=eureka-server
server.port=8761
#设置eureka实例名称,与配置文件的变量为主
eureka.instance.hostname=eureka2
#设置服务注册中心地址,指向另一个注册中心
eureka.client.serviceUrl.defaultZone=http://eureka1:8761/eureka/
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka成功启动如图所示
image.png在高可用的Eureka中构建provider服务
UserController
package com.bjsxt.controller;
import java.util.ArrayList;
import java.util.List;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bjsxt.pojo.User;
@RestController
public class UserController {
@RequestMapping("/user")
public List<User> getUsers(){
List<User> list = new ArrayList<>();
list.add(new User(1,"zhangsan",20));
list.add(new User(2,"lisi",22));
list.add(new User(3,"wangwu",20));
return list;
}
}
User
package com.bjsxt.pojo;
public class User {
private int userid;
private String username;
private int userage;
public int getUserid() {
return userid;
}
public void setUserid(int userid) {
this.userid = userid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getUserage() {
return userage;
}
public void setUserage(int userage) {
this.userage = userage;
}
public User(int userid, String username, int userage) {
super();
this.userid = userid;
this.username = username;
this.userage = userage;
}
public User() {
super();
// TODO Auto-generated constructor stub
}
}
网友评论