У меня есть простая регистрация bean-компонентов здесь во время выполнения, которая не работает:
@GetMapping("/hi")
public void hi()
{
MyClass myClass = new MyClass();
genericApplicationContext.registerBean("mybean", MyClass.class, myClass);
}
@GetMapping("/bye")
public Integer bye()
{
MyClass myClass = (MyClass) genericApplicationContext.getBean("mybean");
return myClass.hi;
}
Вызов метода hi()
все идет нормально, однако, когда я вызываю bye()
метод, я получаю это исключение:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mybean': Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)] with root cause
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mybean': Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
Что здесь происходит?