diff --git a/jcommon/docean-plugin/docean-plugin-test/pom.xml b/jcommon/docean-plugin/docean-plugin-test/pom.xml
index 318e75249..8a9a6e63a 100644
--- a/jcommon/docean-plugin/docean-plugin-test/pom.xml
+++ b/jcommon/docean-plugin/docean-plugin-test/pom.xml
@@ -12,7 +12,7 @@
run.mone
docean
- 1.4-SNAPSHOT
+ 1.4-jdk20-SNAPSHOT
org.msgpack
diff --git a/jcommon/docean-plugin/docean-plugin-test/src/test/java/com/xiaomi/youpin/docean/plugin/test/ConfigPluginTest.java b/jcommon/docean-plugin/docean-plugin-test/src/test/java/com/xiaomi/youpin/docean/plugin/test/ConfigPluginTest.java
new file mode 100644
index 000000000..4c226d576
--- /dev/null
+++ b/jcommon/docean-plugin/docean-plugin-test/src/test/java/com/xiaomi/youpin/docean/plugin/test/ConfigPluginTest.java
@@ -0,0 +1,22 @@
+package com.xiaomi.youpin.docean.plugin.test;
+
+import com.xiaomi.youpin.docean.Ioc;
+import com.xiaomi.youpin.docean.plugin.test.config.ConfigService;
+import org.junit.Test;
+
+/**
+ * @author goodjava@qq.com
+ * @date 2023/12/8 13:46
+ */
+public class ConfigPluginTest {
+
+
+ @Test
+ public void testConfigPlugin() {
+ Ioc ioc = Ioc.ins().init("com.xiaomi.youpin.docean.plugin.test.config","com.xiaomi.youpin.docean.plugin.config");
+ ConfigService configService = ioc.getBean(ConfigService.class);
+ System.out.println(configService.getVal());
+ System.out.println(configService.hi());
+ }
+
+}
diff --git a/jcommon/docean-plugin/docean-plugin-test/src/test/java/com/xiaomi/youpin/docean/plugin/test/config/ConfigService.java b/jcommon/docean-plugin/docean-plugin-test/src/test/java/com/xiaomi/youpin/docean/plugin/test/config/ConfigService.java
new file mode 100644
index 000000000..1514888bb
--- /dev/null
+++ b/jcommon/docean-plugin/docean-plugin-test/src/test/java/com/xiaomi/youpin/docean/plugin/test/config/ConfigService.java
@@ -0,0 +1,30 @@
+package com.xiaomi.youpin.docean.plugin.test.config;
+
+import com.xiaomi.youpin.docean.anno.Service;
+import com.xiaomi.youpin.docean.plugin.config.anno.Value;
+import lombok.Getter;
+
+import javax.annotation.Resource;
+
+/**
+ * @author goodjava@qq.com
+ * @date 2023/12/8 13:47
+ */
+
+@Service
+public class ConfigService {
+
+ @Resource(name = "^ddd")
+ private Demo demo;
+
+ @Getter
+ @Value("$ddd")
+ private String val;
+
+ public String hi() {
+ return demo.hi();
+ }
+
+
+
+}
diff --git a/jcommon/docean-plugin/docean-plugin-test/src/test/java/com/xiaomi/youpin/docean/plugin/test/config/Demo.java b/jcommon/docean-plugin/docean-plugin-test/src/test/java/com/xiaomi/youpin/docean/plugin/test/config/Demo.java
new file mode 100644
index 000000000..f05bb2bb8
--- /dev/null
+++ b/jcommon/docean-plugin/docean-plugin-test/src/test/java/com/xiaomi/youpin/docean/plugin/test/config/Demo.java
@@ -0,0 +1,16 @@
+package com.xiaomi.youpin.docean.plugin.test.config;
+
+import com.xiaomi.youpin.docean.anno.Component;
+
+/**
+ * @author goodjava@qq.com
+ * @date 2023/12/8 14:04
+ */
+@Component
+public class Demo {
+
+ public String hi() {
+ return "hi";
+ }
+
+}
diff --git a/jcommon/docean-plugin/docean-plugin-test/src/test/resources/config.properties b/jcommon/docean-plugin/docean-plugin-test/src/test/resources/config.properties
index d2cfaaa0a..91f22526a 100644
--- a/jcommon/docean-plugin/docean-plugin-test/src/test/resources/config.properties
+++ b/jcommon/docean-plugin/docean-plugin-test/src/test/resources/config.properties
@@ -54,3 +54,6 @@ influx_rententionPolicy=1h
#uds_path=/tmp/test.sock
#uds_app=test_app
+
+val=123
+ddd=com.xiaomi.youpin.docean.plugin.test.config.Demo
diff --git a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Ioc.java b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Ioc.java
index 9c8781d10..308737084 100644
--- a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Ioc.java
+++ b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Ioc.java
@@ -307,7 +307,7 @@ public void removeBean(String name) {
private void initIoc0(String name, Bean bean, Field field) {
String realName = getRealName(name);
Bean b = this.beans.get(realName);
-
+
//If it is an implemented interface, check whether a unique implementation class can be matched.
if (!Optional.ofNullable(b).isPresent() && getBean(Cons.AUTO_FIND_IMPL, "false").equals("true")) {
Class clazz = field.getType();
@@ -334,8 +334,9 @@ private void initIoc0(String name, Bean bean, Field field) {
}
private String getRealName(String name) {
- //替换成配置中的值
- if (name.startsWith("$")) {
+ //替换成配置中的值(Resource中的name)
+ if (name.startsWith("^")) {
+ name = "$" + name.substring(1);
Bean bean = this.beans.get(name);
if (null != bean) {
return bean.getObj().toString();
diff --git a/jcommon/docean/src/test/java/com/xiaomi/youpin/docean/test/IocTest.java b/jcommon/docean/src/test/java/com/xiaomi/youpin/docean/test/IocTest.java
index d25614da2..6759723f5 100644
--- a/jcommon/docean/src/test/java/com/xiaomi/youpin/docean/test/IocTest.java
+++ b/jcommon/docean/src/test/java/com/xiaomi/youpin/docean/test/IocTest.java
@@ -146,13 +146,12 @@ public void testIoc6() {
@Test
public void testIoc7() {
-
Ioc ioc = Ioc.ins()
.putBean("$demoName", "com.xiaomi.youpin.docean.test.demo.mydemo.MyDemo1")
.init("com.xiaomi.youpin.docean.test.demo.mydemo");
-
DemoCall dc = ioc.getBean(DemoCall.class);
System.out.println(dc.hi());
+ System.out.println(dc.getVal());
}
diff --git a/jcommon/docean/src/test/java/com/xiaomi/youpin/docean/test/demo/mydemo/DemoCall.java b/jcommon/docean/src/test/java/com/xiaomi/youpin/docean/test/demo/mydemo/DemoCall.java
index ef53068bb..30d76f925 100644
--- a/jcommon/docean/src/test/java/com/xiaomi/youpin/docean/test/demo/mydemo/DemoCall.java
+++ b/jcommon/docean/src/test/java/com/xiaomi/youpin/docean/test/demo/mydemo/DemoCall.java
@@ -1,6 +1,8 @@
package com.xiaomi.youpin.docean.test.demo.mydemo;
import com.xiaomi.youpin.docean.anno.Service;
+import lombok.Getter;
+import org.springframework.beans.factory.annotation.Value;
import javax.annotation.Resource;
@@ -17,6 +19,11 @@ public class DemoCall {
private MyDemo demo;
+ @Getter
+ @Value("$val")
+ private String val;
+
+
//This is just an interface, but if it only has one implementation class, then Ioc will automatically find this unique implementation class.
@Resource
private ICall call;
diff --git a/jcommon/docean/src/test/resources/config.properties b/jcommon/docean/src/test/resources/config.properties
index 0940249c2..cc623e74e 100644
--- a/jcommon/docean/src/test/resources/config.properties
+++ b/jcommon/docean/src/test/resources/config.properties
@@ -6,5 +6,7 @@ download_file_path=/tmp/v
demoVo=com.xiaomi.youpin.docean.test.demo.DemoVo
+val=123
+
diff --git a/jcommon/openai/src/main/java/run/mone/openai/OpenaiCall.java b/jcommon/openai/src/main/java/run/mone/openai/OpenaiCall.java
index 2c65952ee..8f4fafa1d 100644
--- a/jcommon/openai/src/main/java/run/mone/openai/OpenaiCall.java
+++ b/jcommon/openai/src/main/java/run/mone/openai/OpenaiCall.java
@@ -265,7 +265,7 @@ public void onClosed(EventSource eventSource) {
@Override
public void onFailure(EventSource eventSource, @Nullable Throwable t, @Nullable Response response) {
- log.error("on failure error:" + t, t);
+ log.error("on failure error:" + response, t);
}
});
}
diff --git a/jcommon/openai/src/test/java/run/mone/openapi/OpenApiTest.java b/jcommon/openai/src/test/java/run/mone/openapi/OpenApiTest.java
index c37f33d55..1c25e6a22 100644
--- a/jcommon/openai/src/test/java/run/mone/openapi/OpenApiTest.java
+++ b/jcommon/openai/src/test/java/run/mone/openapi/OpenApiTest.java
@@ -26,6 +26,7 @@
import io.reactivex.disposables.Disposable;
import lombok.Data;
import lombok.SneakyThrows;
+import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import okhttp3.sse.EventSource;
import okhttp3.sse.EventSourceListener;
@@ -168,7 +169,7 @@ private OpenAiClient client() {
public void testCallStream() {
String key = System.getenv("open_api_key");
CountDownLatch latch = new CountDownLatch(1);
- OpenaiCall.callStream(key, null, "天空为什么是蓝色的", new String[]{}, new StreamListener() {
+ OpenaiCall.callStream(key, "", "天空为什么是蓝色的", new String[]{}, new StreamListener() {
@Override
public void onEvent(String str) {
System.out.println(str);
@@ -178,6 +179,11 @@ public void onEvent(String str) {
public void end() {
latch.countDown();
}
+
+ @Override
+ public void onFailure(Throwable t, Response response) {
+ System.out.println(t + "" + response);
+ }
});
latch.await();
}