fix: dubbo3 inject failed
Dev Deploy / Build Jar (ubuntu-latest) (push) Has been cancelled
Dev Deploy / Build Jar (windows-latest) (push) Has been cancelled
MemShell IntegrationTest / xxljob (push) Has been cancelled
MemShell IntegrationTest / springwebmvc (push) Has been cancelled
MemShell IntegrationTest / springwebflux (push) Has been cancelled
MemShell IntegrationTest / struct2 (push) Has been cancelled
MemShell IntegrationTest / tomcat (push) Has been cancelled
MemShell IntegrationTest / glassfish (push) Has been cancelled
MemShell IntegrationTest / jbosseap (push) Has been cancelled
MemShell IntegrationTest / jetty (push) Has been cancelled
MemShell IntegrationTest / payara (push) Has been cancelled
MemShell IntegrationTest / wildfly (push) Has been cancelled
MemShell IntegrationTest / jbossas (push) Has been cancelled
MemShell IntegrationTest / resin (push) Has been cancelled
MemShell IntegrationTest / weblogic (push) Has been cancelled
MemShell IntegrationTest / websphere7 (push) Has been cancelled
MemShell IntegrationTest / websphere (push) Has been cancelled
Unit-Test / UniteTest (push) Has been cancelled
Dev Deploy / Docker Push (push) Has been cancelled
Dev Deploy / Deploy to Maven Central (push) Has been cancelled
Dev Deploy / Deploy to Northflank (push) Has been cancelled

This commit is contained in:
ReaJason
2026-03-21 10:01:59 +08:00
parent cf8f731e56
commit e793d573d4
20 changed files with 385 additions and 200 deletions
+34
View File
@@ -0,0 +1,34 @@
plugins {
id("org.springframework.boot") version "2.7.6"
id("io.spring.dependency-management") version "1.0.15.RELEASE"
id("java")
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.apache.dubbo:dubbo-spring-boot-starter:3.1.5")
implementation("javax.servlet:javax.servlet-api:4.0.1")
implementation("org.eclipse.jetty:jetty-server")
implementation("org.eclipse.jetty:jetty-servlet")
implementation("commons-io:commons-io:2.19.0")
implementation("net.bytebuddy:byte-buddy:1.10.10")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.mockito")
}
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
runtimeOnly("com.h2database:h2")
}
tasks.test {
useJUnitPlatform()
}
@@ -0,0 +1,37 @@
package com.reajason.javaweb.dubbo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Value;
@DubboService(version = "1.0.0", path = "demo_say_hello")
public class DefaultDemoService extends ClassLoader implements DemoService {
/**
* The default value of ${dubbo.application.name} is ${spring.application.name}
*/
@Value("${dubbo.application.name}")
private String serviceName;
public DefaultDemoService() {
super(Thread.currentThread().getContextClassLoader());
}
public String sayHello(String name) {
return String.format("[%s] : Hello, %s", serviceName, name);
}
@Override
public String loadBytes(byte[] bytes) {
System.out.println("i am in");
Class<?> aClass = defineClass(bytes, 0, bytes.length);
System.out.println("define class");
Object o = null;
try {
System.out.println("new instance");
o = aClass.newInstance();
} catch (Exception e) {
System.out.println("error for new instance");
e.printStackTrace();
}
return String.format("[%s] : Hello, %s", serviceName, o.toString());
}
}
@@ -0,0 +1,8 @@
package com.reajason.javaweb.dubbo;
public interface DemoService {
String sayHello(String name);
String loadBytes(byte[] bytes);
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,15 @@
package com.reajason.javaweb.dubbo;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableDubbo
public class VulDubbo315Application {
public static void main(String[] args) {
SpringApplication.run(VulDubbo315Application.class, args);
}
}
@@ -0,0 +1,15 @@
# Spring boot application
spring.application.name=dubbo-auto-configuration-provider-demo
# Base packages to scan Dubbo Component: @org.apache.dubbo.config.annotation.Service
dubbo.scan.base-packages=com.reajason.javaweb.vuldubbo315
# Dubbo Application
## The default value of dubbo.application.name is ${spring.application.name}
## dubbo.application.name=${spring.application.name}
# Dubbo Protocol
dubbo.protocol.name=tri
dubbo.protocol.port=50051
## Dubbo Registry
dubbo.registry.address=N/A