Skip to content

Ioc工厂方法的唯一参数是变长参数的话会抛异常 #1160

Description

@wendal

https://nutz.cn/yvr/t/ukcm3djno6i4ioij56due023u2

public static Server createTcpServer(String... args) throws SQLException {
    TcpServer service = new TcpServer();
    Server server = new Server(service, args);
    service.setShutdownHandler(server);
    return server;
}
h2Server : {
    type : "org.h2.tools.Server",
    args : [
        [ "-tcp", "-tcpAllowOthers", "-tcpPort", "8082" ]
    ],
    factory : "org.h2.tools.Server#createTcpServer",
    events : {
        create : "start",
        depose : "stop"
    }
}
Exception in thread "main" org.nutz.ioc.IocException: [h2Server] # FAIL to create Ioc Bean name=[h2Server]
    at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:149)
    at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
    at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
    at org.gx.shiro.Main.main(Main.java:32)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.NoSuchMethodException: Fail to find Method org.h2.tools.Server->createTcpServer with params:
["java.util.ArrayList"]
    at org.nutz.lang.Mirror.findMethod(Mirror.java:1142)
    at org.nutz.lang.Mirror.findMethod(Mirror.java:1118)
    at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:101)
    ... 8 more

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions