运行时怎么修改annotation注解的值

57 阅读1分钟

首先要实现org.springframework.beans.factory.config.BeanPostProcessor接口

image.png 并覆盖postProcessAfterInitialization方法进行修改

image.png

如果运行中出现如下错误

image.png 在启动参数中添加

--add-opens java.base/java.lang=ALL-UNNAMED 
--add-opens java.base/java.lang.reflect=ALL-UNNAMED 
--add-opens java.base/java.lang.invoke=ALL-UNNAMED 
--add-opens java.base/java.math=ALL-UNNAMED 
--add-opens java.base/sun.net.util=ALL-UNNAMED 
--add-opens java.base/java.io=ALL-UNNAMED 
--add-opens java.base/java.net=ALL-UNNAMED 
--add-opens java.base/java.nio=ALL-UNNAMED 
--add-opens java.base/java.security=ALL-UNNAMED 
--add-opens java.base/java.text=ALL-UNNAMED 
--add-opens java.base/java.time=ALL-UNNAMED 
--add-opens java.base/java.util=ALL-UNNAMED 
--add-opens java.base/sun.reflect.annotation=ALL-UNNAMED