Hello World
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick StartCreate a new post1$ hexo new "My New Post"
More info: Writing
Run server1$ hexo server
More info: Server
Generate static files1$ hexo generate
More info: Generating
Deploy to remote sites1$ hexo deploy
More info: Deployment
前后端跨域问题
前后端跨域问题什么是前后端跨域问题启动前端工程,工程首页不能正常显示,查看浏览器报错如下
1Access to XMLHttpRequest at 'http://localhost:63110/system/dictionary/all' from origin 'http://localhost:8601' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
提示:从http://localhost:8601 访问 http://localhost:63110/system/dictionary/all 被 CORS policy 阻止,因为没有Access-Control-Allow-Origin 头信息。CORS全称是 cross origin resource share 表示跨域资源共享。
从一个地址请求另一个地址,如果协议、主机、端口三者全部一 ...
Swagger
Swagger什么是Swagger?
OpenAPI规范(OpenAPI Specification 简称OAS)是Linux基金会的一个项目,试图通过定义一种用来描述API格式或API定义的语言,来规范RESTful服务开发过程,并且已经发布并开源在GitHub上:https://github.com/OAI/OpenAPI-Specification
Swagger是全球最大的OpenAPI规范(OAS)API开发工具框架,Swagger是一个在线接口文档的生成工具,前后端开发人员依据接口文档进行开发,只要添加Swagger的依赖和配置信息即可使用它
1.引入依赖
123456<!-- Spring Boot 集成 swagger --><dependency> <groupId>com.spring4all</groupId> <artifactId>swagger-spring-boot-starter</artifactId> <version>1.9.0.RELEASE ...
RPC小记
RPC小记
源码参考:https://github.com/Snailclimb/guide-rpc-framework
参考文档:https://www.yuque.com/books/share/b7a2512c-6f7a-4afe-9d7e-5936b4c4cab0
动态代理首先看客户端的代码
12345678@RpcScan(basePackage = {"com.richcoder"})public class ClientMain { public static void main(String[] args) throws InterruptedException { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(ClientMain.class); HelloController controller = (HelloControll ...
Netty优化与源码
Netty优化序列化序列化和反序列化主要用在对消息正文的转换上
序列化时,需要将 Java 对象变为要传输的数据
反序列化时,需要将传入的正文数据还原成 Java 对象
目前我们的代码仅支持 Java 自带的序列化和反序列化方式
123456789// 序列化ByteArrayOutputStream bos = new ByteArrayOutputStream();ObjectOutputStream oos = new ObjectOutputStream(bos);oos.writeObject(message);byte[] bytes = bos.toByteArray();// 反序列化ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(content));Message message = (Message) ois.readObject();
为了后续能更好的扩展序列化的使用,我们抽象一个 Serializer 接口,专门用于处理序列化的方式
1234567public ...
Netty入门与实践
NettyNetty 是一个异步的、基于事件驱动的网络应用框架,用于快速开发可维护、高性能的网络服务器和客户端
Netty的异步还是基于多路复用的,并没有实现真正意义上的异步IO
Hello world
服务端代码
123456789101112131415161718192021222324252627282930public class HelloServer { public static void main(String[] args) { // 1.启动器 负责组装netty组件 启动服务器 new ServerBootstrap() // 2.BossEventLoop WorkerEventLoop(selector, thread) 组成NioEventLoop .group(new NioEventLoopGroup()) // 3.选择服务器ServerSocketChannel的实现 .ch ...
Non-blocking I/O
ByteBufferJava NIO系统的核心在于:通道(Channel)和缓冲区(Buffer)。通道表示打开到 IO 设备(例如:文件、套接字)的连接。若需要使用 NIO 系统,需要获取用于连接 IO 设备的通道以及用于容纳数据的缓冲区。然后操作缓冲区,对数据进行处理
ByteBuffer入门案例首先我们创建一个txt文件,其内容为:
11234567890abc
接着编写代码获取文件内容
1234567891011121314151617181920212223242526@Slf4jpublic class TestByteBuffer { public static void main(String[] args) { // 获取Channel 这里获取的是FileChannel try (FileChannel channel = new FileInputStream("data.txt").getChannel()) { // 准备缓冲区 B ...
Spring小记
Spring 小记摘抄自 Spring揭秘
BeanFactoryProcessor
PropertyPlaceholderConfiguration: 帮助解析xml文件中的数据源配置内容
123456<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}"></property> <property name="url" value="${jdbc.url}"></property> <property name="username" value="${jdbc.username}& ...







