Spring Framework 5.0:@Controller、@Service、@Repository

@Repository注解:Spring数据访问层的契约与治理基石 在Spring框架中,@Repository是一个语义化注解,用于标识数据访问层组件。它不仅触发Bean自动注册,更关键的是激活PersistenceExceptionTranslationPostProcessor异常翻译机制,将JDBC、MyBatis等底层技术异常统一转换为Spring标准的DataAccessException体系,提升错误处理的可维护性与一致性。该注解还作为事务切面(TransactionInterceptor)和APM监控埋点的语义锚点,支撑分布式系统中的可观测性与稳定性保障。广 阅读详情

回顾

http://blog.youkuaiyun.com/github_26672553/article/details/78214223
http://blog.youkuaiyun.com/github_26672553/article/details/78793707
1、我们了解了什么是“注解”
2、通过注解的方式可以非常方便的加载组件Bean
3、使用包扫描的方式加载Bean


@Configuration  // 表明这是一个配置类
public class MyConfig {
    /**
     * 用户登录验证配置方法
     * @return 返回这个验证条件配置对象
     */
    @Bean
    public UserValidateConfig userValidateConfig1(){
        // 设置好验证条件:用户名长度8、QQ必填
        UserValidateConfig userValidateConfig = new UserValidateConfig(){
            {
                setUserNameLength(8);
                setQQRequired(true);
            }
        };

        return userValidateConfig;
    }

    @Bean
    @Qualifier("us1")
    public UserService myUserService(){
        UserService userService = new UserService();
        userService.setUserValidateConfig(this.userValidateConfig1());
        return userService;
    }

    @Bean
    @Qualifier("us2")
    public UserService myUS(){
        UserService userService = new UserService();
        userService.setUserValidateConfig(this.userValidateConfig1());
        return userService;
    }

    @Bean
    public NewsService myNewsService(){
        return new NewsService();
    }
}

回过头来想想:难道为了配合IoC容器,我们把所有需要用到的Bean都在这里配置?
那岂不是要写好多@Bean ?而且有的类没有什么太负载的对象依赖,我们仅仅是想在IoC容器中统一使用而已。

我们有必要学几个新注解

下面4个注解都可以标注Bean,官方文档告诉我们未来将会对它们进行扩展,但也给出了基本函数:

@Service 用于标注业务层组件
@Controller 用于标注控制层组件(MVC常用)
@Repository 用于标注数据访问组件
@Component 泛指组件,当组件不好归类的时候,我们可以使用这个注解进行标注

案列:获取用户虚拟币

1、请复习数据库连接池和JOOQ这个ORM框架知识
http://blog.youkuaiyun.com/github_26672553/article/details/78190246
http://blog.youkuaiyun.com/github_26672553/article/details/78191576

我们现在使用注解来改造一下,新建文件UserConfig.java,代码如下:

package SpringLean.Users;


import org.apache.tomcat.jdbc.pool.DataSource;
import org.apache.tomcat.jdbc.pool.PoolProperties;
import org.jooq.DSLContext;
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.sql.Connection;
import java.sql.SQLException;

@Configuration
public class UserConfig {

    @Bean
    public PoolProperties poolProperties(){
        return new PoolProperties(){
            {
                setUrl("jdbc:mysql://127.0.0.1/test?characterEncoding=UTF-8");
                setUsername("root");
                setPassword("root");
                setDriverClassName("com.mysql.jdbc.Driver");

                setMinIdle(5); //始终保留的连接的最小连接数,默认10
                setMinIdle(10); //设置池内最大空闲连接数
                setInitialSize(5); //启动时初始连接数 默认10
                setMaxActive(20); //最大活跃连接数
                setTestOnBorrow(true); //取出连接时是否对其进行验证
                setValidationQuery("select 1"); //如果上面设置为true,则这里要设置
            }
        };
    }

    @Bean
    public  Connection getConnection() throws SQLException {
        DataSource dataSource = new DataSource();
        dataSource.setPoolProperties(this.poolProperties());
        Connection connection = dataSource.getConnection();

        return connection;
    }

    @Bean
    public DSLContext dslContext() throws SQLException {
        return DSL.using(this.getConnection(), SQLDialect.MYSQL);
    }
}

2、我们的案列是为了学习前面说到的那几个新的注解,所以处于学习目的,我们设计一下简单的结构:

入口函数:初始化IoC容器,加载Bean
UserController:用于最终如何展现用户信息(虚拟币)
UserService:用于获取用户信息的业务逻辑
UserRepository:数据库增删改查

需要特殊说明的是:这样分开是一种良好的规范模式,并不是说非要这样做。

UserController.java文件:

package SpringLean.Users;

import org.springframework.stereotype.Controller;

@Controller
public class UserController {

}

UserService.java文件:

package SpringLean.Users;

import org.springframework.stereotype.Service;

@Service
public class UserService {
}

UserRepository.java文件:

package SpringLean.Users;

import org.springframework.stereotype.Repository;

@Repository
public class UserRepository {

}

你已经看出来的,就是给类打上不同的注解。

SpringFramework实战指南(五) 在我们使用 XML 方式管理 bean 的时候,每个 bean 都有一个唯一标识——id 属性的值,便于在其他地方引用。现在使用注解后,每个组件仍然应该有一个唯一标识。和 XML 配置文件一样,注解本身并不能执行,注解本身仅仅只是做一个标记,具体的功能是框架检测到注解标记的位置,然后针对这个位置按照注解标记的功能来执行具体操作。墙上的标记相当于我们在代码中使用的注解,后面同学们做的工作,相当于框架的具体操作。举例:元旦联欢会要布置教室,蓝色的地方贴上元旦快乐四个字,红色的地方贴上拉花,黄色的地方贴上气球。 阅读详情

相关推荐

【RF】Receiver Function接收函数:从理论到实践的深度解析

本文深入解析地震学中的接收函数(Receiver Function, RF)技术,从理论原理到实践操作。文章将RF比作地球的“听诊器”,详细阐述了其通过反褶积剥离震源影响、揭示地下结构(如莫霍面)的核心机制,并提供了使用Python和rf库进行数据处理、计算、动校正与叠加的完整实战流程,同时探讨了其应用、局限性与常见问题的解决方案。

Jerry的专栏 121

Spring注解之Service详解

使用Service注解的服务类为其他组件提供了一种复用业务逻辑的方法,能够减少重复代码的编写,提高代码的可维护性。常常与控制器组件和逻辑层的请求处理组件搭配使用:在控制器组件中注入服务类实例,然后使用该实例调用服务类的业务逻辑,将结果返回给请求处理组件。

juggle_gap_horse的博客 2万+

OpenCV学习笔记(25)基于MFC和OpenCV的摄像机定标与立体匹配测试程序(20140505更新)

最近整理了一下这两年一直在用的摄像机定标与立体匹配测试程序,将代码进行了重构,界面也做了调整,分享出来方便有需要的朋友使用。当然我的编程能力有限,程序可能还有各种bug,请大家多多包涵。相关问题欢迎留言或email联系讨论,谢谢! ==================================================================================源码

晨宇思远 5万+

spring中service层是干嘛的

Service层在Spring框架中起到了连接Controller层和DAO层的桥梁作用,负责处理核心的业务逻辑,管理事务,验证数据,并提供可复用的服务接口。通过合理的分层设计,可以显著提高应用程序的可维护性和可扩展性。是Spring框架提供的一个注解,用于声明式事务管理。它可以帮助开发者更方便地管理和控制事务,确保在执行数据库操作时,多个操作要么全部成功,要么全部失败,从而保证数据的一致性和完整性。以下是注解是Spring框架中用于声明式事务管理的重要工具。通过在方法或类上添加。

qq_43518966的博客 1620

易康eCognition9.0分类|规则集和机器学习的方法的面向对象的多尺度分割分类

基于易康eCognition9.0软件的规则集和机器学习的方法的面向对象的多尺度分割分类

weixin_46493028的博客 1万+

零基础学习大气污染模式(WRF、WRF-chem、smoke、camx等)

零基础学习大气污染模式(WRF、WRF-chem、smoke、camx等)

weixin_56135535的博客 652

五、 Spring Framework基础:Spring Data JPA基本用法与 Repository 接口

除了基本操作,还可以通过方法命名规则定义自定义查询。Spring Data JPA 会根据方法名自动解析并生成对应的 SQL 查询。Spring Data JPA 是一个功能强大的数据访问框架,通过接口继承和方法命名规则,极大地简化了数据访问层的开发工作。本文详细介绍了 Spring Data JPA 的基本用法,包括实体类的定义、Repository 接口的使用以及数据访问的实现。希望这些内容能帮助你在实际开发中更好地使用 Spring Data JPA。如果你对某个部分有更多问题,欢迎随时交流!

xiaoqi270620903的专栏 992

历年北京理工大学复试专业综合题

。

A place to record sth. 2万+

Spring技术内幕之Spring Data JPA-自定义Repository实现

1.自定义Repository方法接口,让接口的实现类来继承这个中间接口而不是Repository接口package com.data.jpa.dao; import java.io.Serializable;import java.util.List;import java.util.Map; import org.springframework.da...

diaojin6880的博客 555

高通camera驱动 camx read xml 和 probe 流程 和 sensor I2C读写的波形图 (三)

Camx 刚接触的时候对于这个xml 一脸懵逼,实际上和mm-camera差不多就是以xml node节点的方式标准化了driver相关的code,exposure 和 gain的逻辑实现还是在同级目录的cpp中,并且将 xml 的解析工作放在了 out/target/<product>/gen/STATIC_LIBERARIES/libcamxgenerated_intermediates/generated/ 中主要是包含了: g_chromatix : tuning 相关xml的解析co

shangbolei的博客 1万+

Unreal5从入门到精通之如何在VR中使用3DUI

前面我们讲过《Unreal5从入门到精通之UMG的使用》一般制作游戏时,UI都是添加到屏幕视窗上面的,但是在制作VR时,我们往往需要制作一个3D的UI,放置在场景中,然后使用手柄的射线来和UI进行交互。今天我们就来讲解下,如何在VR中创作和交互3DUI首次操作会感觉好复杂,多多练习,当你熟悉了UE蓝图的操作后会发现,这只是一个常规的蓝图操作而已。祝大家在虚幻的学习过程中非常顺利。希望这篇博客对你有所帮助。

TxNet 1982

Spring Data JPA框架系列(五)-Repository创建实例详解

1 创建Repository实例对象 本节主要介绍如何为自定义repository接口创建实例和bean定义。一种方法是使用Spring命名空间,该命名空间随每个支持repository机制的Spring Data模块一起提供,尽管我们一般建议使用Java配置。 1.1. XML 配置文件方式 每个Spring Data模块都包括一个repositories元素,让你定义Spring为你自动扫描的基础包路径,如下例所示。 例1:通过XML配置文件的方式获取Spring Data repository实例 &

最爱嫣夜来 2314

物料分类账-返工工单(自身)差异分摊逻辑

如上图所示,当月入库的全部消耗,而返工消耗的数量为100PCS,所以返工消耗占总消耗的比例为100pcs/(205pcs+100pcs)=0.327868852。备注:红色箭头的物料号为产品自己本身所产生的价差,就是返工工单所承担的差异,而我们要计算的就是这个值,所以计算价差不会包括此项。价差合计就是不包括初始分摊的价差9153.7,剩下的价差合计就是返工工单自身所承担的差异4465.21。每一次返工工单所承担的差异都会按照价差*承担比例去计算承担的差异,知道承担完所有差异。

Yeol827的博客 2484

java之什么是注解(Annotations)

什么是Annotations

LM Wang的专栏 585

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Spring Framework 注解大全

Spring IOC/DI 相关注解 @Configuration 等价于applicationContext.xml配置 @Configuration public class ApplicationConfig { //... } 使用程序实现加载工厂 AnnotationConfigApplicationContext ctx= new AnnotationConfigA...

高興 1857

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Spring framework(十)基于注解装配Bean

一、装配Bean的注解 XML配置文件可以实现装配Bean,但是如果应用中Bean的数量较多,会导致XML配置文件过于臃肿,给升级维护带来一定的困难。 JDK5.0以后,提供了Annotation(注解)功能,Spring2.5版本也提供了对Annotation技术的全面支持,可以使用注解来配置依赖注入。 Spring默认不使用注解装配Bean,因此需要在XML配置文件中添加context:annotation-config/开启注解。 注解包含如下: 注解 描述 @Component 它是

全栈攻城狮JSON的博客 745

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Spring Framework 常见类速查

本文总结了Spring Framework的核心概念和常用类,帮助开发者快速构建心智模型。核心围绕IoC/DI、Bean和ApplicationContext展开,介绍了启动流程(@SpringBootApplication、SpringApplication)、Bean定义与注入方式(@Component、@Bean、@Primary等),以及Web层常用注解(@RestController、@RequestMapping等)。同时列举了资源处理(Resource体系)和实用工具类(StringUtils

zx020986的博客 568

Spring Framework-模式注解装配

自定义注解并且被@Service注解标记,同样具有被Spring管理的能力。用来标记被Spring Framework管理的Bean。定义User实体,并且用@CustomizedService标记。Spring Framework注解。web控制器模式注解。

ilwoziji的博客 142

Spring Framework @ComponentScan注解

Spring Framework @ComponentScan注解

一起coding,一起嗨。 663

走向自动装配|第一章-Spring Framework 手动装配

走向自动装配|第一章-Spring Framework 手动装配 文章目录走向自动装配|第一章-Spring Framework 手动装配文章说明1.Spring 模式注解装配2.Stereotype Annotations 模式注解3.装配方式4.自定义模式注解4.1 @Component "派生性"4.2 @Component "层次性"4.3 @SpringBootApplication5.参考 文章说明 Spring Framework 到 Spring Boot 怎么一步一步走向自动装配 第一

谢文峰的博客 391

Spring之Spring Framework详解

特性Bean 加载时机懒加载预加载(启动时实例化单例)国际化不支持支持(MessageSource)事件机制不支持支持(ApplicationEvent)资源加载不支持通配符支持(classpath*:)AOP 集成需手动配置自动集成适用场景资源受限环境企业级应用(推荐)-- 开启注解扫描 --> < context: component-scan base-package = " com.example " /> <!

萧瑟余晖的博客 419

Java27:SPRING

声明式事务是指使用注解或者XML配置的方式来控制的事务的提交和回滚。开发者只需要添加配置即可,具体事务的实现由第三方框架实现,避免我们直接进行事务操作使用声明式事务可以将事务的控制和业务逻辑分离开来,提高代码的可读性和可维护性区别:编程式事务需要手动编写代码来管理事务而声明式事务可以通过配置文件或注解控制事务。

zzx_nihao的博客 1058

Spring全家桶面试题(一)之Spring Framework(五)

1.因为BeanDefinition会在ioc容器加载的先注册, 而BeanFactoryPostProcess就是在所有的BeanDefinition注册完后做扩展的,所以要 先加载BeanFactoryPostProcess 2. 解析配置类的组件 它就实现BeanFactoryPostProcess, 所以要先去加载BeanFactoryPostProcessBean的创建顺序是由BeanDefinition的注册顺序来决定的, 当然依赖关系也会影响Bean创建顺序 (A-B)。主要是由注解(

TPH_BETTER.的博客 290

SSM框架---Spring的注解(三)

一、Spring的注解 1、注解的开发步骤 ①导包spring-aop.jar ②开启注解扫描器(告诉spring容器应该去哪个目录下解析注解 <context:component-scan base-package="com.ly.spring" />) ③配置注解组件 @Component @Controller @Service @Repository ④测试 2、常用...

qq_37358143的博客 256

Spring框架入门及使用

Spring框架入门及使用

w2687713610的博客 297

Spring:注解开发定义bean

Component@Service这对于@Component注解,衍生出了其他三个注解@Service衍生的这三个注解和@Component注解的作用是一样的,任意使用具有相同的效果。为什么要衍生出这三个呢?方便我们后期在编写类的时候能很好的区分出这个类是属于表现层业务层还是数据层的类。

qq_41187116的博客 889
上一篇: Spring Framework 5.0:注解的方式加载Bean之包扫描、@Autowired
下一篇: Spring Framework 5.0:Resources资源文件获取接口
学习笔记666
博客等级 码龄12年 1047粉丝 1369原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值