Demo entry 6783510

javas

   

Submitted by anonymous on Feb 15, 2019 at 02:11
Language: Java. Code size: 474 Bytes.

package com.example.demo.config;


import com.example.demo.bean.Student;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyAppConfiguration {

    @Bean  //将方法的返回值添加到容器中;容器中这个组件默认的id就是方法名
    public Student firstStudent(){
        System.out.println("配置类@Bean给容器中添加组件firstStudent...");
        Student student = new Student(    );
        return student;
    }
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).