답변

2

자바에서는 객체를 인스턴스화하는 유일한 방법은 생성자를 호출하는 것입니다. new 연산자 또는 리플렉션을 사용하여 생성자를 호출 할 수 있습니다.

스프링을 사용하여 물체를 설치합니다.

0

여기에 표시됩니다.

스프링 IoC 컨테이너는 하나 이상의 빈을 관리합니다. 이 빈은 컨테이너에 제공된 구성 메타 데이터에 정의 된 지침 (일반적으로 XML 정의 형식)을 사용하여 작성됩니다. 컨테이너 자체 내에서 ,이 빈 정의는 (다른 정보들)을 포함하는 BeanDefinition 객체, 다음과 같은 메타 데이터로 표시됩니다 :

1. A package-qualified class name: this is normally the actual implementation class of the bean being defined. However, if the bean is to be instantiated by invoking a static factory method instead of using a normal constructor, this will actually be the class name of the factory class. 
    2. Bean behavioral configuration elements, which state how the bean should behave in the container (prototype or singleton, autowiring mode, initialization and destruction callbacks, and so forth). 
    3. Constructor arguments and property values to set in the newly created bean. An example would be the number of connections to use in a bean that manages a connection pool (either specified as a property or as a constructor argument), or the pool size limit. 
    4. Other beans which are needed for the bean to do its work, that is collaborators (also called dependencies). 

그래서, 당신은 용기 자체가 콩 만드는 방법에는 핸들이 없습니다 참조하십시오. new 연산자 대신 Java에서 객체를 쉽게 만들 수 있습니다.

0

1 비공개 생성자가 정의되어 있고 구성 메타 데이터에서 동일한 것으로 선언 된 클래스는 리플렉션을 사용하여 인스턴스화됩니다. getDeclaredConstructor() of a classAPI

  1. 일부 클래스는 메타 데이터에 정의 된 경우 정적 또는 비 정적 팩토리 메소드를 사용하여 인스턴스화된다. spring documentation

    에서

섹션 4.3.2을 읽어 보시기 바랍니다 인스턴스화 콩

관련 문제