踩点记录-_-!!!

JDK17踩坑

为什么要用jdk17?因为生产用了zgc,想要本地测试zgc参数,而mac/AArch64想要使用zgc,只能17版本,详情可以查看官网:https://wiki.openjdk.org/display/zgc/Main

各种unnamed module的报错

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @7791a895
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
	at com.google.inject.internal.cglib.core.$ReflectUtils$1.run(ReflectUtils.java:52)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
	at com.google.inject.internal.cglib.core.$ReflectUtils.<clinit>(ReflectUtils.java:42)
	... 75 more

解决:增加如下vm参数

–add-opens java.base/java.lang=ALL-UNNAMED
–add-opens java.base/sun.net.util=ALL-UNNAMED
–add-opens java.base/java.util=ALL-UNNAMED
–add-opens java.base/java.lang.reflect=ALL-UNNAMED
–add-opens java.base/java.text=ALL-UNNAMED
–add-opens java.desktop/java.awt.font=ALL-UNNAMED
–add-opens java.desktop/sun.swing=ALL-UNNAMED

maven打包报错

报错如下

class lombok.javac.apt.LombokProcessor (in unnamed module @0x3ed27f49) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x3ed27f49

原因:lombok版本过低

解决:引入更高版本

    	<dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.24</version>
            <scope>compile</scope>
        </dependency>

Cacheable注解踩坑

语法错误

报错如下

org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'notification' cannot be found on object of type 'org.springframework.cache.interceptor.CacheExpressionRootObject' - maybe not public or not valid?

	at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:217)
	at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:104)
	at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:91)
	at org.springframework.expression.spel.ast.OpMinus.getValueInternal(OpMinus.java:98)
	at org.springframework.expression.spel.ast.OpMinus.getValueInternal(OpMinus.java:98)

配置如下

@Cacheable(key = "notification-all-category", cacheNames = "userSwitch")

原因:如果缓存的key是常量,需要使用单引号将常量包起来
解决方法:修改配置如下

@Cacheable(key = "'notification-all-category'", cacheNames = "userSwitch")

类型转换错误

报错如下

java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.util.List (java.lang.Boolean and java.util.List are in module java.base of loader 'bootstrap')
	at ....notification.service.template.TemplateService$$EnhancerBySpringCGLIB$$67b21dc9.selectAllValidShownCategoryCodes(<generated>)
	at ....notification.controller.UserSwitchSettingController.queryUserSwitch(UserSwitchSettingController.java:123)

报错代码

@Cacheable(key = "'notification-all-category'", cacheNames = "userSwitch")
public List<TemplateCategoryEntity> selectAllValidShownCategoryCodes() {
	return templateCategoryMapper.selectAllValidShownCategoryCodes();
}

检查Mapper响应类型没问题,那么就是缓存问题,查看userSwitch缓存配置为Boolean类型-.-!!!
新增缓存并配置匹配的序列化类型

private RedisCacheConfiguration getAllCategoryCacheConfiguration() {
    return RedisCacheConfiguration
            .defaultCacheConfig()
            .serializeValuesWith(new RedisSerializationContext.SerializationPair<List<TemplateCategoryEntity>>() {
                @Override
                public RedisElementReader<List<TemplateCategoryEntity>> getReader() {
                    return byteBuffer -> JacksonUtil.fromList(new String(byteBuffer.array(), StandardCharsets.UTF_8 ),
                            TemplateCategoryEntity.class);
                }

                @Override
                public RedisElementWriter<List<TemplateCategoryEntity>> getWriter() {
                    return o -> ByteBuffer.wrap(JacksonUtil.toJsonStr(o).getBytes(StandardCharsets.UTF_8));
                }
            })
            .entryTtl(Duration.ofDays(30))
            .prefixKeysWith("notification_category_");
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据引用和引用,出现错误"npm ERR! code EPERM npm ERR! syscall mkdir npm ERR! path D:\Java kaifa software\node.js\_cacache npm ERR! errno -4048"是由于权限不足引起的。EPERM错误通常表示在执行文件或目录操作时缺少必要的权限。这可能是由于安装node.js时选择了错误的安装路径或者没有管理员权限导致的。为了解决这个问题,你可以尝试以下几个步骤: 1. 确保你以管理员身份运行命令提示符或终端。右键点击命令提示符或终端,并选择“以管理员身份运行”。 2. 检查你的安装路径是否包含特殊字符或空格。引用中提到的路径"D:\Java kaifa software\node.js\_cacache"包含了空格和中文字符,在某些情况下会导致权限问题。你可以尝试将安装路径更改为不包含特殊字符和空格的路径,例如"D:\nodejs\_cacache"。 3. 确保你具有对安装路径和相关文件的读写权限。你可以右键点击安装路径文件夹,选择“属性”,然后在“安全”选项卡中检查你的用户是否具有适当的权限。 4. 尝试使用命令提示符或终端以管理员身份重新运行安装命令。在命令提示符或终端中,输入"npm install -g @vue/cli"并按下回车键。 如果以上步骤都无法解决问题,你可能需要联系系统管理员或更换安装路径来解决权限问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [出现npm ERR code EPERM npm ERR syscall mkdir npm ERR path B:\nodejs\node_global\_cacache 的解决方法](https://blog.csdn.net/weixin_47872288/article/details/121978948)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [npm ERR! code EPERM npm ERR! syscall open npm ERR! path C:\Program Files\nodejs\node_cache\_cacache\](https://download.csdn.net/download/weixin_38663701/14040568)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [安装Nodejs踩过的坑:npm安装... code EPERM npm ERR! syscall mkdir npm ERR! path D:\Program Files\nod..)](https://blog.csdn.net/m0_52309938/article/details/120689806)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值