Matlab调用Java版JPEG2000图像压缩工具:jj2000-4.1

2023-12-16 21:10

本文主要是介绍Matlab调用Java版JPEG2000图像压缩工具:jj2000-4.1,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Matlab调用Java版JPEG2000图像压缩工具:jj2000-4.1


0. 简介

0.1. JPEG与JPEG2000

大家知道JPEG是基于离散余弦变换(DCT)的图像压缩标准,而JPEG2000是基于小波变换(DWT)的图像压缩标准,当然不同的还有编码算法。JPEG与JPEG2000及其扩展 Joint Photographic Experts Group 组织创建和维护, 更多信息参见维基百科:JPEG2000,或者JPEG官网: http://www.jpeg.org/,里面提供了C++、C、Java等语言的实现,请根据需要自行下载。

0.2. jj2000简介

JJ2000实现的是JPEG2000标准中的part1部分,纯由Java语言写成,项目官网:http://jpeg2000.epfl.ch/,但该网址本人试图访问多次,未果;在JPEG官网也提供了下载链接:https://code.google.com/p/jj2000/,不过版本号是5.1,此外Google Code明年将关闭服务,本人将其导出到了GitHub,下载链接点我。对于文章使用的版本下载,待会介绍。


1. 工具

硬件:PC机

软件:Matlab、Jpeg2000Gui、Java虚拟机、jj2000-4.1

Note:软件工具下载链接请百度或谷歌,当然,Jpeg2000Gui、jj2000-4.1、以及Google基于jj2000-5.1修改的的jj2000-master,也可以点此下载。

             Jpeg2000Gui 是Nikola Sprljan 写的一个调用jj2000-4.1.jar工具包的 matlab GUI 程序,为方便使用,本人进行了一定的修改。


2. 步骤与方法

2.0 安装软件工具

没有安装MATLAB 和 Java虚拟机的,请自行安装。Java虚拟机根据自己需要选择,有:Microsoft JVM,Sun‘s Java等等,’其环境变量的配置,见2.1软件配置。

Jpeg2000Gui 和 jj2000-4.1无需安装,解压即可。


2.1 软件配置

2.1.1 Java虚拟机的环境变量配置

按照提示安装好Java虚拟机后,还需要配置环境变量,按照下述流程打开环境变量设置页:

控制面板(Control Panel)——> 系统(system)——>  高级系统设置(Advanced system settings)——> 高级(Advanced)——> 环境变量(Environment Variables)


图2-1 环境变量设置界面

如上图所示,包含两类环境变量:用户环境变量 和 系统环境变量。我们需要在用户环境变量中添加 JAVA_HOME 环境变量,在系统变量里添加 CLASSPATH 环境变量 和 新建(如果没有的话)或修改(如果有的话)PATH环境变量。它们的值如下面绿色部分:

JAVA_HOME=JavaPath(JavaPath是Java的安装路径,如E:\Program Files\Java\jdk1.7.0_51

PATH=.;%JAVA_HOME%\bin(等同于E:\Program Files\Java\jdk1.7.0_51\bin)

CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;

下面,给出图解

参照上图2-1,点击“用户变量(User Variables for ... )” 区域的“新建(New)”,在弹出窗口中,按下图输入, 点击OK,创建JAVA_HOME环境变量,注意你的JAVA安装路径。


图2-2 JAVA_HOME 环境变量

参照上图2-1,点击“系统环境变量(System variables)” 区域的“新建(New)”,在弹出窗口中,输入CLASSPATH环境变量名,及其对应的值,点击OK创建。

参照上图2-1,找到“系统环境变量(System variables)” 区域PATH环境变量,点击“编辑(Edit)”,在变量值前端输入PATH的值,如下图2-3所示:


图2-3 给Path环境变量添加值

这样环境变量就配置好了。

测试:为了测试环境变量配置是否成功,在运行里输入cmd,打开DOS窗口,输入:Java -version,若输出下图所示信息,则表明配置成功。


图2-4 Java 的环境变量配置成功

2.1.2 jj2000-4.1.jar工具包的环境变量配置

在jj2000-4.1文件夹中找到jj2000-4.1.jar (没有的话自行编译),并将其复制到要存放的路径下。

jj2000-4.1.jar是一个Java类包,为了能够在任意路径下自由调用,将其路径添加进上面建立的CLASSPATH环境变量里去。假设jj2000-4.1.jar的路径是:

D:\Workspace\Matlab\DIP\jpeg2000\Jpeg2000Gui\jj2000-4.1.jar,那么,就把它添加进CLASSPATH环境变量的值里面,用; 隔开,这样就添加好了。


测试:为了测试环境变量配置是否成功,在运行里输入cmd,打开DOS窗口,输入:Java JJ2KEncoder -u,若输出下图所示信息,则表明配置成功,此命令是查看 JJ2KEncoder 的使用帮助。


图2-5 JJ2KEncoder 参数选项

2.2 jj2000-4.1.jar 的使用

找到jj2000中的 README 文件,使用写字板打开,在里面可以找到,jj2000-4.1工具的调用方法。下面进行简要介绍:


Windows下,使用命令添加环境变量:set CLASSPATH=<jjdir>/jj2000-4.1.jar;%CLASSPATH%,其中,<jjdir>,为jj2000-4.1.jar 所在文件夹路径。


本文使用的是Sun的JDK,编解码命令如下,其它虚拟机请参见 README 文件。


2.2.1 DOS下执行编解码

Windows下,编码命令:

                                          java JJ2KEncoder <args>

                         解码命令:

                                          java JJ2KDecoder <args>

其中,<args>,为可选参数,使用Java JJ2KEncoder -u 可以查看具体参数选项,如-i 是输入文件参数,-o 是输出文件参数,-rate 用以指定压缩比。


如下命令,以“pict.pgm”文件为输入,进行8倍的压缩编码,输出文件为“pict_JJ2.j2k”。

Java JJ2KEncoder -i pict.pgm -o pict_JJ2.j2k -rate 1

 

2.2.2 Matlab下通过DOS执行

如果在Matlab下调用,可以使用Matlab自带的  dos  函数,将命令加载到DOS运行,格式如下,其中,cmdstr为命令字符串。

[s,w] = dos(cmdstr)


2.2.3 Matlab下直接执行Java命令

如果想直接在Matlab中使用Java命令,需要在Java命令前加感叹号 ! ,如在Matlab命令窗口,输入:!Java -version,则输出,下图所示信息:



图2-6 在Matlab中查看 Java 版本信息

同样,如果想运行 JJ2KEncoder 命令,可以使用:

!Java JJ2KEncoder -i pict.pgm -o pict_JJ2.j2k -rate 1


2.2.4 Jpeg2000Gui 运行结果示例

Jpeg2000Gui 实现了在Matlab下的调用,请参考之,下面给出本人修改后的一个运行结果图。


图2-7 jpeg2000Gui 运行结果示例

图中实现的是 16 倍的压缩,PSNR在23.0dB,还是很高的!

3. Note

1. 如果出现Matlab调用不成功,而在DOS下调用成功的情况,请注销重启系统

2. 在dos下 输入:Java JJ2KEncoder -u >>C:\help.txt,可以将结果输出到help.txt文件。

4. 附录

4.1 JJ2KEncoder参数选项

Usage:JJ2KEncoder args...The exit code of the encoder is non-zero if an error occurs.Note: Many encoder modules accept tile-component specific parameters. Theseparameters must be provided according to the pattern:"[<tile-component idx>] <param>" (repeated as many time as needed).<tile-component idx> respect the following policy according to the degreeof priority:(1) t<idx> c<idx> : Tile-component specification.(2) t<idx> : Tile specification.(3) c<idx> : Component specification(4) <void> : Default specification.Where the priorities of the specifications are:(1) > (2) > (3) > (4), ('>' means "overrides")<idx>: ',' separates indexes, '-' separates bounds of indexes list. (ex:0,2-4 means indexes 0,2,3 and  4).The following arguments are recognized:-u [on|off] (default = off)Prints usage information. If specified all other arguments (except 'v')are ignored-v [on|off] (default = off)Prints version and copyright information.-verbose (default = on)Prints information about the obtained bit stream.-o <file name>Mandatory argument. This option specifies the name of the output fileto which the codestream will be written.-i <image file> [<image file> [<image file> ... ]]Mandatory argument. This option specifies the name of the input imagefiles. Supported formats are PGM (raw), PPM (raw) and PGX, which is asimple extension of the PGM file format for single component datasupporting arbitrary bitdepths. If the extension is '.pgm', PGM-rawfile format is assumed, if the extension is '.ppm', PPM-raw file formatis assumed, otherwise PGX file format is assumed. PGM and PPM files areassumed to be 8 bits deep. A multi-component image can be specified byeither specifying several PPM and/or PGX files, or by specifying onePPM file.-lossless [on|off] (default = off)Specifies a lossless compression for the encoder. This options isequivalent to use reversible quantization ('-Qtype reversible') and 5x3wavelet filters pair ('-Ffilters w5x3'). Note that this option cannotbe used with '-rate'. When this option is off, the quantization typeand the filters pair is defined by '-Qtype' and '-Ffilters'respectively.-rate <output bitrate in bpp> (default = 100)This is the output bitrate in bits per pixel.-tref <x> <y> (default = 0 0)Sets the origin of the tile partitioning on the reference grid, withrespect to the canvas origin. The value of 'x' ('y') specified can notbe larger than the 'x' one specified in the ref option.-ref <x> <y> (default = 0 0)Sets the origin of the image in the canvas system. It sets thecoordinate of the top-left corner of the image reference grid, withrespect to the canvas origin-tiles <nominal tile width> <nominal tile height> (default = 0 0)This option specifies the maximum tile dimensions to use. If bothdimensions are 0 then no tiling is used.-tile_parts <packets per tile-part> (default = 0)This option specifies the maximum number of packets to have in onetile-part. 0 means include all packets in first tile-part of each tile-pfile <filename of arguments file>Loads the arguments from the specified file. Arguments that arespecified on the command line override the ones from the file.The arguments file is a simple text file with one argument per line ofthe following form:<argument name>=<argument value>If the argument is of boolean type (i.e. its presence turns a featureon), then the 'on' value turns it on, while the 'off' value turns itoff. The argument name does not include the '-' or '+' character. Longlines can be broken into several lines by terminating them with ''.Lines starting with '#' are considered as comments. This option is notrecursive: any 'pfile' argument appearing in the file is ignored.-pph_main [on|off] (default = off)Packs the packet headers in the main header.-pph_tile [on|off] (default = off)Packs the packet headers in the tile headers.-file_format [on|off] (default = off)Puts the JPEG 2000 codestream in a JP2 file format wrapper.-disable_jp2_extension [on|off] (default = off)JJ2000 automatically adds .jp2 extension when using'file_format'option. This option disables it when on.-debug (default = off)Print debugging messages when an error is encountered.-Mct [<tile index>] [on|off] ...Specifies to use component transformation with some tiles.  If thewavelet transform is reversible (w5x3 filter), the Reversible ComponentTransformation (RCT) is applied. If not (w9x7 filter), the IrreversibleComponent Transformation (ICT) is used.-Ffilters [<tile-component idx>] <id> [ [<tile-component idx>] <id> ...]Specifies which filters to use for specified tile-component.<tile-component idx>: see general note<id>: ',' separates horizontal and vertical filters, ':' separatesdecomposition levels filters. JPEG 2000 part I only supports w5x3 andw9x7 filters.-Wwt [full] (default = full)Specifies the wavelet transform to be used. Possible value is: 'full'(full page). The value 'full' performs a normal DWT.-Wlev <number of decomposition levels> (default = 5)Specifies the number of wavelet decomposition levels to apply to theimage. If 0 no wavelet transform is performed. All components and alltiles have the same number of decomposition levels.-Qguard_bits [<tile-component idx>] <gb> [ [<tile-component idx>] <gb>...] (default = 2)The number of bits used for each tile-component in the quantizer toavoid overflow (gb).-Qstep [<tile-component idx>] <bnss> [ [<tile-component idx>] <bnss> ...](default = 0.0078125)This option specifies the base normalized quantization step size (bnss)for tile-components. It is normalized to a dynamic range of 1 in theimage domain. This parameter is ignored in reversible coding.-Qtype [<tile-component idx>] <id> [ [<tile-component idx>] <id> ...]Specifies which quantization type to use for specified tile-component.By default (if '-lossless is not specified'), the quantization stepsize is 'expounded'.<tile-component idx> : see general note.<id>: Supported quantization types specification are : 'reversible' (noquantization), 'derived' (derived quantization step size) and'expounded'.Example: -Qtype reversible or -Qtype t2,4-8 c2 reversible t9 derived.-Rno_rect [on|off] (default = off)This argument makes sure that the ROI mask generation is not done usingthe fast ROI mask generation for rectangular ROIs regardless of whetherthe specified ROIs are rectangular or not-Rstart_level <level> (default = -1)This argument forces the lowest <level> resolution levels to belong tothe ROI. By doing this, it is possible to avoid only gettinginformation for the ROI at an early stage of transmission.<level> = 0means the lowest resolution level belongs to the ROI, 1 means the twolowest etc. (-1 deactivates the option)-Ralign [on|off] (default = off)By specifying this argument, the ROI mask will be limited to coveringonly entire code-blocks. The ROI coding can then be performed withoutany actual scaling of the coefficients but by instead scaling thedistortion estimates.-Rroi [<component idx>] R <left> <top> <width> <height> or [<componentidx>] C <centre column> <centre row> <radius> or [<component idx>] A<filename>Specifies ROIs shape and location. The shape can be either rectangular'R', or circular 'C' or arbitrary 'A'. Each new occurrence of an 'R', a'C' or an 'A' is a new ROI. For circular and rectangular ROIs, allvalues are given as their pixel values relative to the canvas origin.Arbitrary shapes must be included in a PGM file where non 0 valuescorrespond to ROI coefficients. The PGM file must have the size as theimage. The component idx specifies which components contain the ROI.The component index is specified as described by points 3 and 4 in thegeneral comment on tile-component idx. If this option is used, thecodestream is layer progressive by default unless it is overridden bythe 'Aptype' option.-Cpp [<tile-component idx>] <dim> <dim> [<dim> <dim>] [ [<tile-componentidx>] ...]Specifies precinct partition dimensions for tile-component. The firsttwo values apply to the highest resolution and the following ones (ifany) apply to the remaining resolutions in decreasing order. If lessvalues than the number of decomposition levels are specified, then thelast two values are used for the remaining resolutions.-Clen_calc [<tile-component idx>] near_opt|lazy_good|lazy[[<tile-component idx>] ...] (default = near_opt)Specifies the algorithm to use in calculating the necessary MQ lengthfor each decoding pass. The best one is 'near_opt', which performs arather sophisticated calculation and provides the best results. The'lazy_good' and 'lazy' are very simple algorithms that provide ratherconservative results, 'lazy_good' one being slightly better. Do notchange this option unless you want to experiment the effect ofdifferent length calculation algorithms.-Cterm [<tile-component idx>] near_opt|easy|predict|full[[<tile-component idx>] near_opt|easy|predict|full ...] (default =near_opt)Specifies the algorithm used to terminate the MQ codeword. The mostefficient one is 'near_opt', which delivers a codeword which in almostall cases is the shortest possible. The 'easy' is a simpler algorithmthat delivers a codeword length that is close to the previous one (inaverage 1 bit longer). The 'predict' is almost the same as the 'easy'but it leaves error resilient information on the spare leastsignificant bits (in average 3.5 bits), which can be used by a decoderto detect errors. The 'full' algorithm performs a full flush of the MQcoder and is highly inefficient.It is important to use a good termination policy since the MQ codewordcan be terminated quite often, specially if the 'Cbypass' or'Creg_term' options are enabled (in the normal case it would beterminated once per code-block, while if 'Creg_term' is specified itwill be done almost 3 times per bit-plane in each code-block).-Cseg_symbol [<tile-component idx>] on|off[ [<tile-component idx>] on|off...] (default = off)Inserts an error resilience segmentation symbol in the MQ codeword atthe end of each bit-plane (cleanup pass). Decoders can use thisinformation to detect and conceal errors.'on' enables, 'off' disablesit.-Ccausal [<tile-component idx>] on|off[ [<tile-component idx>] on|off...] (default = off)Uses vertically stripe causal context formation. If this is enabled thecontext formation process in one stripe is independant of the nextstripe (i.e. the one below it). 'on' enables, 'off' disables it.-Creg_term [<tile-component idx>] on|off[ [<tile-component idx>] on|off...] (default = off)If this is enabled the codeword (raw or MQ) is terminated on a byteboundary after each coding pass. In this case it is important to use anefficient termination algorithm, see the 'Cterm' option. 'on' enables,'off' disables it.-CresetMQ [<tile-component idx>] on|off[ [<tile-component idx>] on|off...] (default = off)If this is enabled the probability estimates of the MQ coder are resetafter each arithmetically coded (i.e. non-lazy) coding pass. 'on'enables, 'off' disables it.-Cbypass [<tile-component idx>] on|off[ [<tile-component idx>] on|off...] (default = off)Uses the lazy coding mode with the entropy coder. This will bypass theMQ coder for some of the coding passes, where the distribution is oftenclose to uniform. Since the MQ codeword will be terminated at leastonce per lazy pass, it is important to use an efficient terminationalgorithm, see the 'Cterm' option.'on' enables, 'off' disables it.-Cblksiz [<tile-component idx>] <width> <height> [[<tile-component idx>]<width> <height>] (default = 64 64)Specifies the maximum code-block size to use for tile-component. Themaximum width and height is 1024, however the surface area (i.e. widthx height) must not exceed 4096. The minimum width and height is 4.-Alayers <rate> [+<layers>] [<rate [+<layers>] [...]] (default = 0.015+20 2.0 +10)Explicitly specifies the codestream layer formation parameters. The<rate> parameter specifies the bitrate to which the first layer shouldbe optimized. The <layers> parameter, if present, specifies the numberof extra layers that should be added for scalability. These extralayers are not optimized. Any extra <rate> and <layers> parameters addmore layers, in the same way. An additional layer is always added atthe end, which is optimized to the overall target bitrate of the bitstream. Any layers (optimized or not) whose target bitrate is higherthat the overall target bitrate are silently ignored. The bitrates ofthe extra layers that are added through the <layers> parameter areapproximately log-spaced between the other target bitrates. If several<rate> [+<layers>] constructs appear the <rate> parameters must appearin increasing order. The rate allocation algorithm ensures that allcoded layers have a minimal reasonable size, if not these layers aresilently ignored.-Aptype [<tile idx>] res|layer|res-pos|pos-comp|comp-pos [res_startcomp_start layer_end res_end comp_end prog] [[res_start comp_startly_end res_end comp_end prog] ...] [[<tile-component idx>] ...]Specifies which type of progression should be used when generating thecodestream. The 'res' value generates a resolution progressivecodestream with the number of layers specified by 'Alayers' option. The'layer' value generates a layer progressive codestream with multiplelayers. In any case the rate-allocation algorithm optimizes for bestquality in each layer. The quality measure is mean squared error (MSE)or a weighted version of it (WMSE). If no progression type is specifiedor imposed by other modules, the default value is 'layer'.It is also possible to describe progression order changes. In thiscase, 'res_start' is the index (from 0) of the first resolution level,'comp_start' is the index (from 0) of the first component, 'ly_end' isthe index (from 0) of the first layer not included, 'res_end' is theindex (from 0) of the first resolution level not included, 'comp_end'is index (from 0) of the first component not included and 'prog' is theprogression type to be used for the rest of the tile/image. Severalprogression order changes can be specified, one after the other.-Peph [<tile idx>] on|off[ [<tile  idx>] on|off ...] (default = off)Specifies whether end of packet header (EPH) markers should be  used.'on' enables, 'off' disables it.-Psop [<tile idx>] on|off[ [<tile idx>] on|off ...] (default = off)Specifies whether start of packet (SOP) markers should be used. 'on'enables, 'off' disables it.Send bug reports to: jj2000-bugs@ltssg3.epfl.ch



4.2 JJ2KDecoder参数选项


Usage:JJ2KDecoder args...The exit code of the decoder is non-zero if an error occurs.The following arguments are recongnized:-Cer [on|off] (default = on)Specifies if error detection should be performed by the entropy decoderengine. If errors are detected they will be concealed and the resultingdistortion will be less important. Note that errors can only bedetected if the encoder that generated the data included errorresilience information.-Cverber [on|off] (default = on)Specifies if the entropy decoder should be verbose about detectederrors. If 'on' a message is printed whenever an error is detected.-Rno_roiThis argument makes sure that the no ROI de-scaling is performed.Decompression is done like there is no ROI in the image-cdstr_info (default = off)Display information about the codestream. This information is:- Marker segments value in main and tile-part headers,- Tile-part length and position within the code-stream.-debug (default = off)Print debugging messages when an error is encountered.-parsing (default = on)Enable or not the parsing mode when decoding rate is specified('-nbytes' or '-rate' options). If it is false, the codestream isdecoded as if it were truncated to the given rate. If it is true, thedecoder creates, truncates and decodes a virtual layer progressivecodestream with the same truncation points in each code-block.-nbytes <decoding rate in bytes> (default = -1)Specifies the decoding rate in bytes. The codestream is either parsed(default) or truncated depending the command line option '-parsing'. Tospecify the decoding rate in bits per pixel, use '-rate' optionsinstead.-rate <decoding rate in bpp> (default = 100)Specifies the decoding rate in bits per pixel (bpp) where the number ofpixels is related to the image's original size (Note: this number isnot affected by the '-res' option). The codestream is either parsed(default) or truncated depending the command line option '-parsing'. Tospecify the decoding rate in bytes, use '-nbytes' options instead.-o <filename>This is the name of the file to which the decompressed image iswritten. If no output filename is given, the image is displayed on thescreen. Output file format is PGX by default. If the extension is'.pgm' then a PGM file is written as output, however this is onlypermitted if the component bitdepth does not exceed 8. If the extensionis '.ppm' then a PPM file is written, however this is only permitted ifthere are 3 components and none of them has a bitdepth of more than 8.If there is more than 1 component, suffices '-1', '-2', '-3', ... areadded to the file name, just before the extension, except for PPM fileswhere all three components are written to the same file.-i <filename or url>The file containing the JPEG 2000 compressed data. This can be either aJPEG 2000 codestream or a JP2 file containing a JPEG 2000 codestream.In the latter case the first codestream in the file will be decoded. Ifan URL is specified (e.g., http://...) the data will be downloaded andcached in memory before decoding. This is intended for easy use inapplets, but it is not a very efficient way of decoding network serveddata.-res <resolution level index>Specifies the resolution level wanted for the decoded image (0 meansthe lowest available resolution, the last resolution  level gives animage with original dimension). If given index is greater than thenumber of available resolution levels of the compressed image, thedecoded image has the lowest available resolution (among alltile-components). Note that this option affects only the inversewavelet transform and not the number  of bytes read by the codestreamparser: this number of bytes depends only on options '-nbytes' or'-rate'.-pfile <filename>Loads the arguments from the specified file. Arguments that arespecified on the command line override the ones from the file.The arguments file is a simple text file with one argument per line ofthe following form:<argument name>=<argument value>If the argument is of boolean type (i.e. its presence turns a featureon), then the 'on' value turns it on, while the 'off' value turns itoff. The argument name does not include the '-' or '+' character. Longlines can be broken into several lines by terminating them with '\'.Lines starting with '#' are considered as comments. This option is notrecursive: any 'pfile' argument appearing in the file is ignored.-verbose [on|off] (default = on)Prints information about the decoded codestream-v [on|off] (default = off)Prints version and copyright information-u [on|off] (default = off)Prints usage information. If specified all other arguments (except 'v')are ignoredSend bug reports to: jj2000-bugs@ltssg3.epfl.ch






这篇关于Matlab调用Java版JPEG2000图像压缩工具:jj2000-4.1的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/501901

相关文章

springboot集成easypoi导出word换行处理过程

《springboot集成easypoi导出word换行处理过程》SpringBoot集成Easypoi导出Word时,换行符n失效显示为空格,解决方法包括生成段落或替换模板中n为回车,同时需确... 目录项目场景问题描述解决方案第一种:生成段落的方式第二种:替换模板的情况,换行符替换成回车总结项目场景s

SpringBoot集成redisson实现延时队列教程

《SpringBoot集成redisson实现延时队列教程》文章介绍了使用Redisson实现延迟队列的完整步骤,包括依赖导入、Redis配置、工具类封装、业务枚举定义、执行器实现、Bean创建、消费... 目录1、先给项目导入Redisson依赖2、配置redis3、创建 RedissonConfig 配

SpringBoot中@Value注入静态变量方式

《SpringBoot中@Value注入静态变量方式》SpringBoot中静态变量无法直接用@Value注入,需通过setter方法,@Value(${})从属性文件获取值,@Value(#{})用... 目录项目场景解决方案注解说明1、@Value("${}")使用示例2、@Value("#{}"php

SpringBoot分段处理List集合多线程批量插入数据方式

《SpringBoot分段处理List集合多线程批量插入数据方式》文章介绍如何处理大数据量List批量插入数据库的优化方案:通过拆分List并分配独立线程处理,结合Spring线程池与异步方法提升效率... 目录项目场景解决方案1.实体类2.Mapper3.spring容器注入线程池bejsan对象4.创建

线上Java OOM问题定位与解决方案超详细解析

《线上JavaOOM问题定位与解决方案超详细解析》OOM是JVM抛出的错误,表示内存分配失败,:本文主要介绍线上JavaOOM问题定位与解决方案的相关资料,文中通过代码介绍的非常详细,需要的朋... 目录一、OOM问题核心认知1.1 OOM定义与技术定位1.2 OOM常见类型及技术特征二、OOM问题定位工具

基于 Cursor 开发 Spring Boot 项目详细攻略

《基于Cursor开发SpringBoot项目详细攻略》Cursor是集成GPT4、Claude3.5等LLM的VSCode类AI编程工具,支持SpringBoot项目开发全流程,涵盖环境配... 目录cursor是什么?基于 Cursor 开发 Spring Boot 项目完整指南1. 环境准备2. 创建

Spring Security简介、使用与最佳实践

《SpringSecurity简介、使用与最佳实践》SpringSecurity是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架,本文给大家介绍SpringSec... 目录一、如何理解 Spring Security?—— 核心思想二、如何在 Java 项目中使用?——

SpringBoot+RustFS 实现文件切片极速上传的实例代码

《SpringBoot+RustFS实现文件切片极速上传的实例代码》本文介绍利用SpringBoot和RustFS构建高性能文件切片上传系统,实现大文件秒传、断点续传和分片上传等功能,具有一定的参考... 目录一、为什么选择 RustFS + SpringBoot?二、环境准备与部署2.1 安装 RustF

springboot中使用okhttp3的小结

《springboot中使用okhttp3的小结》OkHttp3是一个JavaHTTP客户端,可以处理各种请求类型,比如GET、POST、PUT等,并且支持高效的HTTP连接池、请求和响应缓存、以及异... 在 Spring Boot 项目中使用 OkHttp3 进行 HTTP 请求是一个高效且流行的方式。

java.sql.SQLTransientConnectionException连接超时异常原因及解决方案

《java.sql.SQLTransientConnectionException连接超时异常原因及解决方案》:本文主要介绍java.sql.SQLTransientConnectionExcep... 目录一、引言二、异常信息分析三、可能的原因3.1 连接池配置不合理3.2 数据库负载过高3.3 连接泄漏