第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

若果需要應用作用域怎么辦

若果需要應用作用域怎么辦

正在回答

1 回答

//定義javaBean

import org.springframework.context.annotation.Scope;

import org.springframework.stereotype.Component;

@Component

@Scope("prototype")

public class Person {

private int id;

private String name;

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

}

//測試類

import org.springframework.context.ApplicationContext;

import org.springframework.context.support.ClassPathXmlApplicationContext;


/**

?* Hello world!

?*

?*/

public class App?

{

? ? public static void main( String[] args )

? ? {

? ? ? ? ApplicationContext appContext = new ClassPathXmlApplicationContext("/spring.xml");

? ? ? ? Person p1 = appContext.getBean(Person.class);

? ? ? ? System.out.println("p1's identityHashCode is " + System.identityHashCode(p1));

? ? ? ??

? ? ? ? Person p2 = appContext.getBean(Person.class);

? ? ? ? System.out.println("p2's identityHashCode is " + System.identityHashCode(p2));

? ? ? ??

? ? }

}

@Scope("")類型不同,作用域范圍不同

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

若果需要應用作用域怎么辦

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號