Search in sources :

Example 1 with Person

use of entity.Person in project lzl_workspace by hpulzl.

the class test method xmlBeanFactory.

public static void xmlBeanFactory() {
    // 加载配置文件
    ClassPathResource resource = new ClassPathResource("ApplicationContext.xml");
    // 解析文件
    BeanFactory beanFactory = new XmlBeanFactory(resource);
    // 创建对应bean,依赖注入过程
    Person p = (Person) beanFactory.getBean("person");
    System.out.println("p = " + p);
}
Also used : XmlBeanFactory(org.springframework.beans.factory.xml.XmlBeanFactory) BeanFactory(org.springframework.beans.factory.BeanFactory) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) XmlBeanFactory(org.springframework.beans.factory.xml.XmlBeanFactory) Person(entity.Person) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 2 with Person

use of entity.Person in project mapstruct by mapstruct.

the class Issue2170Test method shouldGenerateCodeThatCompiles.

@ProcessorTest
public void shouldGenerateCodeThatCompiles() {
    AddressDto addressDto = AddressMapper.INSTANCE.toDto(new Address("10000", Collections.singletonList(new Person("Tester"))));
    assertThat(addressDto).isNotNull();
    assertThat(addressDto.getZipCode()).isEqualTo("10000");
    assertThat(addressDto.getPeople()).extracting(PersonDto::getName).containsExactly("Tester");
}
Also used : Address(org.mapstruct.ap.test.bugs._2170.entity.Address) AddressDto(org.mapstruct.ap.test.bugs._2170.dto.AddressDto) Person(org.mapstruct.ap.test.bugs._2170.entity.Person) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 3 with Person

use of entity.Person in project lzl_workspace by hpulzl.

the class test method defaultListableBeanFactory.

public static void defaultListableBeanFactory() {
    // 加载配置文件
    ClassPathResource resource = new ClassPathResource("ApplicationContext.xml");
    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
    reader.loadBeanDefinitions(resource);
    // 输出
    Person p = (Person) factory.getBean("person");
    System.out.println("p = " + p);
}
Also used : XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) Person(entity.Person) ClassPathResource(org.springframework.core.io.ClassPathResource)

Aggregations

Person (entity.Person)2 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)2 ClassPathResource (org.springframework.core.io.ClassPathResource)2 AddressDto (org.mapstruct.ap.test.bugs._2170.dto.AddressDto)1 Address (org.mapstruct.ap.test.bugs._2170.entity.Address)1 Person (org.mapstruct.ap.test.bugs._2170.entity.Person)1 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)1 BeanFactory (org.springframework.beans.factory.BeanFactory)1 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)1 XmlBeanFactory (org.springframework.beans.factory.xml.XmlBeanFactory)1