From 39b888593a4ef8333a934936315b5963f8d0f75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=97=AD=E8=88=AA?= <3140235434@qq.com> Date: Sun, 6 Apr 2025 21:28:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BAbean-di-annotation.xml,?= =?UTF-8?q?=E4=BF=AE=E6=94=B9TestIoc.java,=E8=A3=85=E9=85=8DBean,=E8=BE=93?= =?UTF-8?q?=E5=87=BAMessage=E5=AE=9E=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bean-di-annotation.xml | 9 +++ .../com/ssm/di/annotation/Message.class | Bin 0 -> 1772 bytes .../ssm/di/annotation/TestAnnotation.class | Bin 429 -> 1045 bytes src/bean-di-annotation.xml | 9 +++ src/com/ssm/di/annotation/Message.java | 62 ++++++++++++++++++ src/com/ssm/di/annotation/TestAnnotation.java | 8 +++ 6 files changed, 88 insertions(+) create mode 100644 out/production/Flowers-SpringProject-2205/bean-di-annotation.xml create mode 100644 out/production/Flowers-SpringProject-2205/com/ssm/di/annotation/Message.class create mode 100644 src/bean-di-annotation.xml create mode 100644 src/com/ssm/di/annotation/Message.java diff --git a/out/production/Flowers-SpringProject-2205/bean-di-annotation.xml b/out/production/Flowers-SpringProject-2205/bean-di-annotation.xml new file mode 100644 index 0000000..be28a11 --- /dev/null +++ b/out/production/Flowers-SpringProject-2205/bean-di-annotation.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/out/production/Flowers-SpringProject-2205/com/ssm/di/annotation/Message.class b/out/production/Flowers-SpringProject-2205/com/ssm/di/annotation/Message.class new file mode 100644 index 0000000000000000000000000000000000000000..1083e7fdb89c6bf1437fe14f1e34bbca74360fe8 GIT binary patch literal 1772 zcmaJ=+foxj5Iqxe&nghP$W3kvApurG0F{eE6h%?0#7dQqn`8)!$!=faNdv z;EQiQXqABF?F0M{E&sx@hg~ji79O^z_w>y4>C-(w|9<%aAcF@{G-D=$CR`Kdx-d6{ znGInsiXdjfm>27UFgL@vCDz3-mcqyi_jU+(LRe<-sYM31!qD-!rdeu*=TuY8m-(Wm z>6T)tx@IzDR&}E!n^i;AN*jh!;m>vBnVjc}X385%!P1Q#Svfi&=ah1d&oTtIg~Je> zNKa;_rWry7U9-4mF~nE5lx;;WD_Tijx5T})KluCI_djo5lcUtEP2CX4x3|AOzhY=m zN_3GgohEEf)l_SNu*67?!JpNO6lz>mHU6kp$#dh0Li|Mvy`YqHilK^s2lQK;Dizeb zTF@)9X;$Q-dXo7=Zkm)ya4&Idg`}Y*Bu>Dz|NMy+kuyrc>|rS_i4m`2qIBeFPivxn zi?}F47cDxqM(Dty9~8K#I4D5jge~3HiL$TjHKV|nRZ*qnP#zb0G9*1aWm??ey0uf~ za#pWYb&YyJHHIp7xe|KOCn1gt5-y@cLYFW-=wN7fw`r-SmW!NPbC6hw^+GMqOSp@B z!jM+6(LSfm^TPtVPi2nw*&UrHDakK!32CGldd_SEL(_5kwfq(@(BuS_YL#o$nK3U- z>tuHLQnlUGyEDVt)5GYex7AEf&kvu_2@Eat7o)Y6zBUu>6d>*D1DzBgJ?jJA6d;Z3 z1D6mbkXk~vpR&lbGFk)4eXx(@_%J{=cmT#QNWNrmz-3&aKZYR;ll}kjC-~mG4!3z8 zPGH12yg;dZB2}_$7rx`v(F3#-0jf--Z?ktf=>;`gBbrB~Jcu-Wa1puWNn{jbbwpCT zXmAr5AR>dO5V3p0Fz!jj?T#_cTRR=sivU1AP88KmY&$ literal 0 HcmV?d00001 diff --git a/out/production/Flowers-SpringProject-2205/com/ssm/di/annotation/TestAnnotation.class b/out/production/Flowers-SpringProject-2205/com/ssm/di/annotation/TestAnnotation.class index 31616bfb39da0ebda1280c5cb02321e9fe981156..eba659e4c27a2df00d93940cb8d84fda9bdc5489 100644 GIT binary patch literal 1045 zcmaJ=TTc@~6#k|y-LkBL<)$doDq^{HP*EQ+CeXyEq9i3ma`A+_$heiU(M- zVd0^T8kQ}rSXgB!zEFWOFB$T+DBxa9^}N(v+LJBfJ9a^ z3;*H0n>vuM-O~NABVVbw1(O%+smCQaxQ6QtJ6ExY`n{eG4R3fNiuQy#eCvCcnNeHX zQUvQ=wLWZN{lxd;6l)gN9n`@Y=CgY};A~;T!6Q6&@C2I{o;rAjHHO9Ppo;}DObn;; zrhOzk)Zpn__NeMtRh(6wV8Zr^;Vki(clej zkQ6=zl#EWdiD9a?d=7H3V>H90!i#~l67l{RFF+Mz^asUH4lEumy~j!7bThg~R?fh_ zB<2Zv7Zat08}#j@4k%-iq)|*^nly3nG4gbP>JQ}JmGfsPG*`A<0Xy0nRn-YANk;R@6T%l z&TLB@b)X4s?p+@*=ICZ*ac{ep16JvD7K3b|k5|{;f;=yU@?5w`JfonLDwrq7i=XsU U&pZW|-!S|Q4NF$3xK6F=3lzx=CIA2c diff --git a/src/bean-di-annotation.xml b/src/bean-di-annotation.xml new file mode 100644 index 0000000..be28a11 --- /dev/null +++ b/src/bean-di-annotation.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/src/com/ssm/di/annotation/Message.java b/src/com/ssm/di/annotation/Message.java new file mode 100644 index 0000000..45b361a --- /dev/null +++ b/src/com/ssm/di/annotation/Message.java @@ -0,0 +1,62 @@ +package com.ssm.di.annotation; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +@Component("message") + +public class Message { + @Value("123456") + private int id; + @Value("好看") + private String content; + @Value("张三") + private String author; + @Value("22") + private String age; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public String getAge() { + return age; + } + + public void setAge(String age) { + this.age = age; + } + + @Override + public String toString() { + return "Messsage{" + + "id=" + id + + ", content='" + content + '\'' + + ", author=" + author + '\'' + + ", age" + age + '\'' + + '}'; + } +} diff --git a/src/com/ssm/di/annotation/TestAnnotation.java b/src/com/ssm/di/annotation/TestAnnotation.java index 5526e92..764b63d 100644 --- a/src/com/ssm/di/annotation/TestAnnotation.java +++ b/src/com/ssm/di/annotation/TestAnnotation.java @@ -1,9 +1,17 @@ package com.ssm.di.annotation; +import com.ssm.di.annotation.Message; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + public class TestAnnotation { public static void main(String[] args) { + ApplicationContext applicationContext = new ClassPathXmlApplicationContext("bean-di-annotation.xml"); + + Message message=(Message) applicationContext.getBean("message"); + System.out.println(message.toString()); } }