当前位置:网站首页>Annotation development management third-party beans
Annotation development management third-party beans
2022-07-26 02:26:00 【lwj_ 07】
One 、 Annotation development management third party bean
Suppose it is also the third-party object that manages the Druids
First step : Import druid coordinate

The second step : stay java Class substituted spring Of xml A method is defined in the configuration file to obtain the information of the third party to be managed bean

The test program :( Step 2 get bean When ,ctx. Method return value type )

The results are shown below :

1.1、 If we want to manage more third-party bean, What shall I do? ( Directly in java Class substituted spring Of xml Define another method in the configuration file )

But there will be a problem if it is written like this , There are many third parties that need to be managed bean When , Always here java Instead of the spring Of xml It is impossible to write in the configuration file , Too much can explode ~
Therefore, we basically need to define a third-party management bean When , Just write an interface and copy the code , stay java Instead of the xml Just annotate the class of the file :
java Class substituted spring Of xml Profile class :

Specifically manage third parties jdbc Of bean Object class :

Sequencing test :

Two 、 Annotation development for third parties bean Inject resources
in other words : For the third party bean Property of
2.1、 Simple type injection
( in other words : For the third party bean Such as private String username; Type of username Attribute assignment )
The code is shown as follows :
java Instead of the spring Of xml Configuration file class for :

The third party bean:

Program testing :

2.2、 Injection of reference types ( !)
边栏推荐
猜你喜欢

MySQL建Websites数据表
![[C] Explain language file operation in detail](/img/12/4affa1d3fb3e4ee126e1c1e3872d9b.png)
[C] Explain language file operation in detail
![[xxl-job] xxl-job learning](/img/2c/d3872983e4228a3ef52a9d1bef836e.png)
[xxl-job] xxl-job learning

C language -- program environment and preprocessing

Prometheus+blackbox exporter+grafana monitoring server port and URL address

1. Mx6ul core module serial Ethernet test (VII)
![[2021] [paper notes] 6G technology vision - otfs modulation technology](/img/50/577ad05bc16e80d1c68eec7b6da988.png)
[2021] [paper notes] 6G technology vision - otfs modulation technology

(Dynamic Programming Series) sword finger offer 48. the longest substring without repeated characters

ES6高级-利用原型对象继承方法

c# 单元测试
随机推荐
Digital warehouse: on the construction practice of digital warehouse in banking industry
Stack Title: the longest absolute path of a file
租户问题。
Keil's operation before programming with C language
massCode 一款优秀的开源代码片段管理器
Pinia plugin persist, a data persistence plug-in of Pinia
18_请求文件
ES6高级-利用原型对象继承方法
增删改查业务的快速上手
Illustration of the insertion process of b+ tree
U++ print information to screen and log
Business Intelligence BI full analysis, explore the essence and development trend of Bi
uni-app跨域配置
17_ Form Data
Is it safe to open galaxy securities account by mobile phone?
[cloud native] 4.1 Devops foundation and Practice
Be careful about bitmap, the "memory Assassin"~
简单使用 MySQL 索引
获取时分秒
我来图书馆小程序一键签到和一键抢位置工具