Shiro was used in an old spring boot project. Recently, Shiro broke a security vulnerability. So we need to upgrade the Shiro version in the project. However, this project was developed by former employees a long time ago, and the source code can no longer be found. So try to upgrade Shiro by replacing jar directly.
Wrong attempt
Usually, HTML can be replaced directly. JS can directly open WinRAR and replace the file directly. I thought jar packages can also be replaced directly. If you find that the jar is directly replaced, an error will be reported.
The error information is as follows:
java -jar spring-zs-1.0-update.jar [18:02:05]
Exception in thread "main" java.lang.IllegalStateException: Unable to open nested entry 'BOOT-INF/lib/shiro-web-1.5.3.jar'. It has been compressed and nested jar files must be stored without compression. Please check the mechanism used to create your executable jar file
at org.springframework.boot.loader.jar.JarFile.createJarFileFromFileEntry(JarFile.java:285)
at org.springframework.boot.loader.jar.JarFile.createJarFileFromEntry(JarFile.java:260)
at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:248)
at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:237)
at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:103)
at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:87)
at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:72)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:49)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Correct steps
Unpack through jar command
My project jar name is spring-zs-1.0. Jar
jar -xvf spring-zs-1.0.jar
After decompression, replace the jar package in./boot-inf/lib directory. I replaced Shiro — 1.2.2.jar with Shiro — 1.5.3.jar
Repackage
jar -cfM0 new.jar ./
This will generate a new jar package!
If you also use MacOS system, you should pay attention to one thing. The MacOS system will automatically generate
. DS in some directories_ Store files, so you should delete these hidden. DS files before repackaging_ Store, otherwise an error will be reported.
reference resources
https://blog.csdn.net/weixin_ 45417347/article/details/101539040
Read More:
- How to select the jar package version for Maven package when the jar package versions referenced by multiple modules are inconsistent
- Spring boot problem 1: error reporting life processing instructions for building a spring boot project
- Zip to decompress the jar package, like the add file in the jar package
- When idea generates a spring boot project, error: read timed out appears
- Update project manually_ Solution of too large jar package in springboot
- Research on Maven management of Java project pom.xml The jar package error is reported, but the project is running normally
- How to turn your project into a jar package in idea
- Spring boot project running error: Servlet.service () for servlet [dispatcherServlet] threw exception
- The spring boot project was first created, pom.xml The error is Maven configuration problem. How to solve it?
- Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.4.0:repackage failed
- The introduction of third-party jar package in mavn project results in classnotfoundexception
- The jar package download of Maven project appears (could not transfer artifact. Org mybatis:mybatis )
- Idea Maven project uses package to package and report error (package does not exist)
- Java project cannot import entity class package and service package, controller layer reports error, fix project setup is OK
- Specify the configuration file when the spring boot command starts
- Does the version of idea2020.1 import mybayis jar package or report an error? Error: (4,28) Java: package org.apache.ibatis.io does not exist
- spring boot Whitelabel Error Page
- Spring boot prompt could not resolve placeholder in string value
- Spring boot problem solving record (1)
- Spring boot running appears java.lang.IllegalStateException : Failed to load ApplicationContext