今天收到邮件 GPT-4 可以开始进行测试了。 有点小激动看看效果怎么样。 https://www.ossez.com/t/gpt-4/14356
今天收到邮件 GPT-4 可以开始进行测试了。 有点小激动看看效果怎么样。 https://www.ossez.com/t/gpt-4/14356
Code Coverage API 这个插件 主要是用于图形化显示你的 Code Coverage。 这个插件不能帮你完成代码覆盖测试,但是能帮你图形化显示下。 查询功能还比较弱,就是好看点吧,实际上对开发人员来说,可能还没有 IntelliJ IDEA 自带的代码覆盖测试运行好用。 https://www.ossez.com/t/code-coverage-api/14355
如果说 Docker 这是虚伪的话,这个虚伪谈不上吧。 DockerHub 的设计上本身的流量成本,存储成本就比其他仓库要大得多。 一个Mave 的 Jar 才多大,一个 Docker 的镜像有多大? 一些项目每个部署个好几次很正常,每次部署 Docker 镜像都要重新生成和推送到 Docker 上,就是一个最简单的 Spring API 也没个几百兆下不来。 这成本,说心里话还是有点同情 Docker 的。 问了下我的 GPT,是这样回答的: 不,Docker不会删除任何的私有镜像,无论是收费的还是免费的。然而,Docker会清洗一些公共镜像,包括那些社区托管及无人支持的,以释放存储空间,节省资源。 看来 GPT 还没有跟上时代。 https://www.ossez.com/t/docker/14348
要搞清楚下载那个版本,请参考文章:来聊聊 OpenJDK 和 JVM 虚拟机 下载地址 semeru 有认证版和非认证版,主要是因为和 OpenJ9 的关系和操作系统的关系而使用不同的许可证罢了,本质代码是一样的。 在 Windows 下没有认证版,直接下开源版就行。 下载地址为:IBM Developer 选择 JDK 17 的 LTS 版本。 注意,开发需要下的是 JDK 。 运行 双击下载后的运行程序来运行安装。 同意许可协议 在这里无脑选择同意后下一步。 设置环境变量 通常我们可以在后面手动设置,在这里就不让操作系统设置了。 继续安装 通过上面的同意后,继续安装。 安装进程 通常安装的过程还是蛮快的,如果你的 Windows 还需要你同意下权限。 安装完成 当安装完成后单击完成按钮。 校验安装 通过在命令行工具中输入查询版本的信息来校验安装。 设置环境变量 因为我的计算机中有多个 Java 环境,为了避免冲突,也把 JAVA_HOME 设置下。 至此 JDK 17 在本地计算机上的安装就已经完成了。 https://www.ossez.com/t/ibm-semeru-windows-jdk-17/14341/1
最近在使用一个 okhttp 的项目运行的时候得到下面的警告信息。 WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by retrofit2.Platform (file:/C:/Users/yhu/.m2/repository/com/squareup/retrofit2/retrofit/2.9.0/retrofit-2.9.0.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int) WARNING: Please consider reporting this to the maintainers of retrofit2.Platform WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 针对这个问题,已经有官方的说明, 说明的地址为:Illegal reflective access · Issue #3341 · square/retrofit · GitHub 解决办法 我们可以有下面的一些解决方案: 可以持续使用 Retrofit 2.8.x 或者更新的版本,或者你可以使用 JDK 17 的版本。 如果你不想升级 JDK 版本的话,你可以继续使用 Retrofit 2.7 版本来避免这个问题。 https://www.ossez.com/t/okhttp-retrofit2/14340
因为 Spring 的发布线路图决定了将要使用 JDK 17 的版本。 查看了下 Oracle 的 JDK 维护版本,JDK 11 显然是一个过度版本,而且马上就要终止支持了。 目前应该是准备升级到 JDK 17 了。 如果你还在使用 JDK 11 的话,是时候考虑要升级了。 https://www.ossez.com/t/jdk-17/14339
当你检出 OpenAI-J 项目以后,你可以对 OpenAI-J 进行测试。 在测试之前你首先需要获得 OpenAI 的 API Key。 OpenAI 的 Key通常是以 sk 开头的字符串。 最简单粗暴的办法就是把获得的 key 替换掉上面的字符串,然后进行测试就可以了。 运行 Unit 测试 在我们的代码中的 Unit 测试中,我们使用了代码: String token = System.getenv("OPENAI_TOKEN"); 上面的代码就是从你的本地环境变量中获得 Key,然后注入到你的代码中。这样的好处是可以避免在提交代码的时候把 key 也一并提交了。 设置环境变量 针对 Windows 环境。 把你的环境变量设置上去,需要注意的是,名称需要和代码中使用的名称一致。 然后直接运行测试程序。 在控制台上,你可以看到 API 调用的输出。 https://www.ossez.com/t/openai-j/14338
因为返回消息的对象不正确,导致有下面的异常: 15:22:28.669 [task-5] DEBUG c.o.w.o.a.i.o.i.WeChatErrorInterceptor - WeChat Response String - {"errcode":0,"errmsg":"ok"} 15:22:28.672 [task-5] ERROR o.s.a.i.SimpleAsyncUncaughtExceptionHandler - Unexpected exception occurred invoking async method: public void com.northtecom.visatrack.api.service.impl.ChatGPTService.processChatGPTContent(java.lang.String) java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "errcode" (class com.ossez.wechat.common.model.WeChatAccessToken), not marked as ignorable (2 known properties: "expires_in", "access_token"]) at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 13] (through reference chain: com.ossez.wechat.common.model.WeChatAccessToken["errcode"]) at io.reactivex.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46) at io.reactivex.internal.observers.BlockingMultiObserver.blockingGet(BlockingMultiObserver.java:93) at io.reactivex.Single.blockingGet(Single.java:2870) at com.ossez.wechat.oa.api.impl.okhttp.WeChatMsgService.sendMessage(WeChatMsgService.java:65) at com.northtecom.visatrack.api.service.impl.WeChatService.sendMessage(WeChatService.java:209) at com.northtecom.visatrack.api.service.impl.ChatGPTService.processChatGPTContent(ChatGPTService.java:94) at com.northtecom.visatrack.api.service.impl.ChatGPTService$$FastClassBySpringCGLIB$$86883789.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:840) Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "errcode" (class com.ossez.wechat.common.model.WeChatAccessToken), not marked as ignorable (2 known properties: "expires_in", "access_token"]) at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 13] (through reference chain: com.ossez.wechat.common.model.WeChatAccessToken["errcode"]) at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61) at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:1127) at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:2036) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1700) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1678) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:320) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177) at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323) at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2051) at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1459) at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:33) at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23) at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243) at retrofit2.OkHttpCall.execute(OkHttpCall.java:204) at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:46) at io.reactivex.Observable.subscribe(Observable.java:12284) at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:35) at io.reactivex.Observable.subscribe(Observable.java:12284) at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(Observ 问题和解决 重新定义 WeChatStatus 对象来处理微信消息发送时候的状态返回。 上面是微信官方网站上提供的返回信息,我们的对象需要和上面的返回信息对应。 修改后的日志能解决这个状态的问题。 https://www.ossez.com/t/api/14337
在 IntelliJ 下调试 PHP 的断点有时候还是比较困惑的。 同时根据你使用的 xdebug 配置也有关系。 xdebug 2.x 下面的配置是 xdebug Version 2 的配置,如果你使用 xdebug 3.x 版本的话,配置是不同的。 [XDebug] zend_extension = "php_xdebug.dll" xdebug.remote_autostart = 1 xdebug.profiler_append = 0 xdebug.profiler_enable = 0 xdebug.profiler_enable_trigger = 0 xdebug.profiler_output_dir = "/xampp/tmp" xdebug.remote_enable = 1 xdebug.remote_handler = "dbgp" xdebug.remote_host = "127.0.0.1" xdebug.remote_log = "/xampp/tmp/xdebug.txt" xdebug.remote_port = 9000 xdebug.trace_output_dir = "/xampp/tmp" xdebug.remote_cookie_expire_time = 36000 xdebug 3.x 下面的配置是 xdebug 3.x 版本的配置,这个版本的配置已经有了不少的修改。 如果直接使用 xdebug 2.x 版本的配置的话,可能会遇到 IntelliJ 断点不停的问题。 [XDebug] zend_extension = "xdebug" xdebug.mode=debug xdebug.client_host = 127.0.0.1 xdebug.client_port = "9003" xdebug.start_with_request=yes 改变 从 xdebug 3.x 开始,默认的调试端口使用了 9003 的端口,这个与 xdebug 2.x 使用的 9000 端口是不一样的。 这个需要注意。 另外:xdebug.start_with_request=yes 参数必须要添加,否则 IntelliJ 的断点不停。 官方的这篇文章:Configure Xdebug | IntelliJ IDEA Documentation 非常值得参考,最好仔细阅读下。 https://www.ossez.com/t/php-windows-xampp-xdebug/14334
需要安装的扩展为: extension=php_mongodb.dll 根据官方的指引:PHP: Installing the MongoDB PHP Driver on Windows - Manual 1 需要到 GitHub 上下载扩展,然后进行安装。 这里的版本选择有些讲究。 首先1.51 是 mongoDB 的驱动版本号,选择最新的就可以了。 8.1 是你的 PHP 版本号,你需要根据你安装的 PHP 版本来选择不同的文件。 TZ 是线程安全,NTZ 非线程安全。一般我们会选择线程安全。 X86 和 X 64 为操作系统的位,如果你是 64 位的操作系统,你就可以选择 64 位的。 如果选择错了,XAMPP 在重启的时候会报错,说你的驱动装不上去。 修改 php.ini 修改 php.ini 配置信息,让 Apache 能够载入 mongoDB 的扩展。 虽然我们下载的文件名称为 php_mongodb.dll,但是在加载扩展的时候,只需要写 mongodb 就可以了,不需要写完整的扩展名字 常见的配置错误信息 我们可能会遇到下面的一些常见问题。 PHP Warning: PHP Startup: Unable to load dynamic library 'php_mongodb.dll' (tried: \\xampp\\php\\ext\\php_mongodb.dll (The specified module could not be found), \\xampp\\php\\ext\\php_php_mongodb.dll.dll (The specified module could not be found)) in Unknown on line 0 [Thu Feb 23 08:27:36.477428 2023] [mpm_winnt:notice] [pid 11368:tid 460] AH00354: Child: Starting 150 worker threads. 上面的问题就是你扩展名字使用得不对,然后 Apache 提示 PHP 找不到对应的扩展。 把扩展名改一下就可以了。 PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb' (tried: \\xampp\\php\\ext\\mongodb (The specified module could not be found), \\xampp\\php\\ext\\php_mongodb.dll (The specified module could not be found)) in Unknown on line 0 [Thu Feb 23 08:31:34.326869 2023] [mpm_winnt:notice] [pid 23212:tid 464] AH00354: Child: Starting 150 worker threads. 上面的问题是你下载扩展的 PHP 版本不兼容。 原因是,我们的 PHP 是 8.1 的,但是扩展我们却使用了 7.1,这个会提示上面的错误信息。 PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb' (tried: \\xampp\\php\\ext\\mongodb (The specified module could not be found), \\xampp\\php\\ext\\php_mongodb.dll (%1 is not a valid Win32 application)) in Unknown on line 0 [Thu Feb 23 08:35:09.928157 2023] [mpm_winnt:notice] [pid 14060:tid 460] AH00354: Child: Starting 150 worker threads. 上面的问题是,你使用的操作系统是 64 位的操作系统,但是你却安装了一个 86(32位)操作系统的扩展。 xampp 通常能够在日志上提供完整的信息,因此只需要根据日志进行修改就可以了。 校验 随后打开 php 的配置信息页面。 如果你能和下面的图一样看到 PHP 有关 mongodb 的配置信息的话,则说明 mongodb 在你的环境下的配置已经成功了。 https://www.ossez.com/t/window-php-xampp-mongodb/14333