Spring + Tomcat项目中nacos配置中文乱码问题解决

Java测试环境搭建全攻略:从Docker容器化到Spring Boot配置实战 在软件工程实践中,环境配置是保障应用稳定运行的基础环节,其核心在于实现隔离性、一致性与可重复性。通过容器化技术如Docker,可以构建轻量、隔离的运行时环境,有效解决“在我机器上能跑”的经典难题。结合Maven/Gradle等构建工具的统一依赖管理,能够确保从开发到测试的依赖版本严格一致,避免因环境差异导致的ClassNotFoundException等运行时问题。对于Java应用,特别是基于Spring Boot的项目,利用多Profile配置机制和外部化配置,可以灵活管理测试环境所需的数据库连接、缓存设 阅读详情

实际工作的时候碰到了nacos中文乱码的问题,一顿排查最终还是调源码解决了。下面为具体的源码流程,有碰到的可以参考下。

对于nacos配置来说,初始主要源码就在NacosConfigService类中。里面有初始化获取配置content以及设置对应监听器的操作。具体可以参考:详解Nacos 配置中心客户端配置缓存动态更新的源码实现 - 简书

对于监听器,我们可以通过注解@NacosConfigListener去自定义监听器。但我们通@NacosValue注解配置的一些配置能进行动态刷新,就意味着nacos内部肯定有自定义的监听器,也是靠这个监听器进行数据的动态刷新。对应的类为NacosPropertySourcePostProcessor,具体的方法流程图如下:

addListenerIfAutoRefreshed -> receiveConfigInfo -> NacosPropertySource newNacosPropertySource = new NacosPropertySource(dataId, groupId, name, config, type);

上述初始化NacosPropertySource 的过程就是导致nacos配置中文乱码的原因
跟进初始化方法如下:
public NacosPropertySource(String dataId, String groupId, String name,
    String nacosConfig, String type) {
		super(name, toProperties(dataId, groupId, nacosConfig, type));
		this.type = type;
}


toProperties(dataId, groupId, nacosConfig, type) -> Co
IntelliJ IDEA + 阿里 Qoder:Spring Boot Agentic 编码实战指南 Agentic 编码是一种以任务规划、工具调用与自主修正为核心的智能开发范式,其本质是将大模型从‘代码补全器’升级为‘IDE 协同代理’。实现该能力需三大支柱:具备完整项目语义索引的 IDE(如 IntelliJ IDEA)、深度蒸馏领域知识的专用 AI 模型(如阿里 Qoder CN),以及轻量可扩展的指令交互协议(如 MCP)。在 Spring Boot 开发中,Qoder 基于 PSI 接口实时感知 Maven 依赖、Bean 上下文与资源配置,结合 MCP 驱动 Apache POI、iText7、 阅读详情

相关推荐

SpringBoot本地运行全流程解析:从环境准备到启动调试避坑指南

SpringBoot作为主流微服务开发框架,凭借内置容器与自动装配机制,极大简化了Java应用的启动与部署。但许多开发者本地运行项目时,常因JDK版本不匹配、Maven依赖下载失败、配置未生效或端口冲突等问题而卡壳。要快速定位故障,需理解其启动链路:构建工具读取依赖、编译源码、SpringApplication启动上下文、内嵌Tomcat监听端口。环境配置与依赖管理是本地运行的基石,Profile隔离、多版本JDK切换、镜像源配置等工程化手段能有效避免重复踩坑。本文从环境准备、项目构建、配置调优、启动调试到

weixin_34038293的博客 400

微服务在线教育系统毕业设计全解析:架构部署到答辩

在互联网应用开发中,微服务架构已成为企业级系统的主流选择,它通过将业务拆分为独立服务,解决了单体应用扩展性差、维护成本高的问题。Spring Boot作为快速构建微服务的利器,搭配Vue实现前后端分离,MySQL存储业务数据,构成了当前高校毕业设计中最常见的技术组合。本文从技术选型、服务拆分、环境搭建、核心功能实现到论文写作与答辩技巧,系统梳理了一套在线教育系统的完整落地路径。无论你是想理解微服务网关、注册中心、JWT鉴权等核心概念,还是希望掌握数据库设计、视频点播、订单支付等业务模块的工程实践,都能从中获

weixin_34320724的博客 399

Java实战:从零构建高并发留学生教务系统(Spring Boot+Vue)

企业级应用开发中,数据库事务与并发控制是保障数据一致性的核心技术。在涉及高并发操作的业务场景(如选课、秒杀)下,不当的锁机制会导致超卖、数据错乱等严重问题。其技术价值在于通过悲观锁、乐观锁或分布式锁等策略,在保证系统性能的同时,确保核心业务流程的原子性与隔离性。本文以留学生教务管理系统的选课模块为具体应用场景,深入剖析了在高并发选课瞬间,如何结合Redis分布式锁与数据库乐观锁,有效解决课程容量超限的经典难题,并分享了从数据库设计到代码实现的完整工程实践方案。

weixin_33922670的博客 319

JSP学生管理系统部署实战:环境配置、避坑指南与二次开发

在JavaWeb开发中,JSP、Servlet、JDBC与MySQL组成的经典技术栈,依然是许多课程设计与毕业设计的核心考察点。这类系统结构清晰,登录、增删改查、分页、搜索等基础功能一应俱全,但其运行环境却往往比代码本身更挑剔。Tomcat版本不兼容、MySQL认证插件冲突、中文乱码、端口占用等问题,常常让新手在部署阶段反复受挫。理解JSP动态页面、Servlet请求控制与JDBC数据库连接的协作原理,是快速定位问题的关键。本文从项目类型识别、环境选型、数据库导入到Tomcat部署,梳理了让一套学生管理源码

weixin_28720573的博客 329

Sourcetree与Gitee的搭配使用

初次将gitee与sourcetree联合起来使用,还是遇到了不少问题,其中最让人烦恼的就是在我修改了一下用户名之后,便无法在Sourcetree直接推送到gitee,很是让人郁闷。本文处理Sourcetree与gitee搭配使用过程中的问题:Sourcetree身份验证失败,无法推送;Sourcetree推送时,无法显示要推送的分支;Sourcetree远端上面有感叹号。

年少时的棉花糖 4433

高速设计注意事项总结——MDI篇

在以太网高速通信系统中,MDI(Medium Dependent Interface,介质相关接口)是连接物理层芯片(PHY)与传输介质(如网线)的关键接口,其设计直接影响信号完整性、传输速率和抗干扰能力。本文围绕 MDI 及 RJ45 接口电路、关键参数、设计与布线要点展开,为高速以太网设计提供参考。本文包含MDI 及 RJ45 接口电路组成、电路设计注意事项、布局布线要求等内容

qq_16237389的博客 1445

SOLIDWORKS Flow Simulation 颗粒分离器仿真:从流场分析到分离效率优化

计算流体力学(CFD)是研究流体流动、传热及相关物理现象的核心工具,其基本原理是通过数值方法求解控制流体运动的纳维-斯托克斯方程。在工程实践中,CFD的价值在于能够对复杂流动进行高保真度仿真,从而在产品设计阶段预测性能、优化结构,显著降低物理样机的试制成本和周期。颗粒分离器作为环保、化工、矿业等领域的关键设备,其设计核心在于平衡分离效率与压力损失。借助SOLIDWORKS内嵌的Flow Simulation模块,工程师可以高效地执行流体仿真,特别是对涉及离散相的颗粒运动进行轨迹追踪和效率统计。该技术方案通过

weixin_28709649的博客 322

避坑指南:在Ubuntu 22.04上配置UR5e与ROS2 Humble真机通信的完整流程

本文详细介绍了在Ubuntu 22.04上配置UR5e机械臂与ROS2 Humble真机通信的完整流程,包括环境准备、网络配置、URCap安装、ROS2驱动部署及控制器状态验证等关键步骤。特别针对常见问题如网络连接失败、驱动启动错误等提供了实用解决方案,帮助工程师高效完成UR5e与ROS2的集成工作。

weixin_30790841的博客 463

基于ResNet + LLM大语言模型的分类识别系统设计与实现,Web前后端分离,Django+vue3+AI助手模块+ResNet50算法+LLM 联动+Element Plus等技术,全网独发

分类识别任务是计算机视觉中的重要任务,广泛应用于智慧校园分类、智慧农业、智慧生活场景分类等领域。常见的分类模型有 VGGNet、ResNet 、MobileNet 、ConvNeXt、DenseNet、ViT、Swin Transformer、YOLOv8/11/26。本项目结合 ResNet分类识别算法 + LLM大语言模型联动 ,使用 Django + Vue3,构建了一个通用的 Web 前后端系统,用户端 + 管理端 ,便于用户操作检,不仅可以用于大论文的工作量展示,还可以作为毕业设计。

在职AI算法工程师,擅长计算机视觉,YOLO目标检测、分割等,擅长web、pyqt界面可视化,好内容持续更新中,来这里跟大家一起学习,共同进步 756

大数据工程中的数据血缘分析工具比较

数据血缘(Data Lineage)是大数据治理中的核心组成部分,它描述了数据从源头到目标的完整流动路径。系统介绍数据血缘的核心概念和技术原理比较主流开源和商业数据血缘工具的功能特点提供数据血缘分析的实践指南和选型建议本文首先介绍数据血缘的基本概念,然后深入分析其技术原理和实现方法,接着比较主流工具的特点,最后通过实际案例展示应用场景。数据血缘(Data Lineage): 描述数据从源头到目标的完整流动路径,包括所有转换和处理步骤元数据(Metadata)

大数据洞察的博客 900

逆向分析-SeparationPreview.aip-分色预览-结构分析(一)-x64dbg条件日志打印-命令表达式-PS脚本

从功能上分析,仅显示使用的专色这个功能,并没有触发插件接口。使用X64dbg加载illustrator进程,切换到句柄窗口,在窗口过程中,右键刷新获取界面。在x64dbg中,在UI中可以输入一些条件表达式,能够计算出对应的值,并打印在日志中。常用的,如果非暂停,输出第一个参数。参数二是utf16的指针,utf16@字符串地址,这里的字符串地址为[[ebp-108]]参数一是utf8的,utf8@字符串地址,这里的字符串地址为[ebp-28]从界面上分析,一个颜色列表,及仅显示专色的多选框组成。

插件开发 643

计算机视觉教程2-3:图解双线性插值算法&最近邻插值算法

提出此算法的背景是基于图片的缩放,在图片缩放的过程中,实质上就是将原图像像素矩阵像素值,填到目标图像像素矩阵中,目标图像像素矩阵可能比原图像像素矩阵大(图片放大),也可能小(图片缩小)。我们假设图片的宽(WidthWidthWidth)和高(HeightHeightHeight)是按同比例缩放的,那么 srcXsrcWidth=dstXdstWidth\frac{srcX}{srcWidth}= \frac{dstX}{dstWidth}srcWidthsrcX​=dstWidthdstX​ ...

FRIGIDWINTER的博客 7281

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: java.lang.NoSuchFieldError: REFLECTION 问题修订
try_learner
博客等级 码龄9年 35粉丝 44原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值