(1)
Java演变过程:JavaSE JavaEE 分布式
(2)
远程服务调用的风格:RPC(主要用于该风格的框架有Dubbo,WebService)和Http(主要用于该风格的框架有RestTemplate),RPC只支持同一个语言,而Http可以支持
多种语言共同开发
(3)
RestTemplate远程服务调用例子
package com.leyou.httpdemo;
import com.leyou.httpdemo.pojo.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.RestTemplate;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = HttpDemoApplication.class)
public class HttpDemoApplicationTests {
@Autowired
private RestTemplate restTemplate;
@Test
public void httpGet() {
//自动将Json转为对象
User user = this.restTemplate.getForObject("http://localhost:8080/mydb/getUsers", User.class);
System.out.println(user.getName());
System.out.println(user.getPassword());
}
}
(4)
springBoot可以给个配置来禁止加载配置文件
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
(5)
@ResponseBody加入这个注解后,默认返回前端的就是Json格式
(6)
spring-eureka类似zookeeper服务注册中心的功能,有接收服务提供方的服务和给予消费方的服务。它是
以eureka作为参照物,其他服务提供者和消费者都是作为客户端(所以加上Client注解),eureka是服务提供者
(7)
Maven dependencies 和 DependencyManagement 区别(两者有显著的区别的,要注意区分)
dependencyManagement:只是声明依赖,并不实现引入,因此子项目需要显示的声明需要用的依赖。如果不在子项目中声明依赖,是不会从父项目中继承下来的;只有在子项目中写了该依赖项,并且没有指定具体版本,才会从父项目中继承该项,并且version和scope都读取自父pom;另外如果子项目中指定了版本号,那么会使用子项目中指定的jar版本
dependencies:相对于dependencyManagement,所有生命在dependencies里的依赖都会自动引入,并默认被所有的子项目继承。
(8)
注意springcloud和springBoot的版本是否冲突
(9)
要实现eureka高可用。前提是保证有多台eureka注册中心,注册中心集群之间互相引用彼此,然后消费方和服务提供方分别调用这些地址即可
(10)
Jetty服务器采用Nio进行网络传输,多用于分布式项目;Tomcat采用Bio网络传输,多用于企业级项目
(11)
总结并发和缓存的区别:并发面临的问题是变量的结果,而缓存面临的时那一瞬间的访问量