Spring Bean Scopes – Singleton and Prototype
springbean
2
singleton
3
prototype
6
Male avatar

loveprogramming viết ngày 28/04/2021

https://grokonez.com/spring-framework/spring-bean-scopes-singleton-prototype

Spring Bean Scopes – Singleton and Prototype

Spring Bean Scopes helps you control the scope of the objects which are created from bean definition. This approach is wonderful because you can choose the scope by configuring bean instead of working at Java class level.

The Spring Framework supports 7 scopes, but this tutorial introduces you 2 of them: singleton scope and prototype scope. The others will be discussed in next article.

I. Technology

  • Java 1.8
  • Maven 3.3.9
  • Spring Tool Suite – Version 3.8.1.RELEASE
  • Spring Boot: 1.4.0.RELEASE

    II. Overview

    1. Goal

    To build a simple application that shows you the way singleton scope and prototype scope act and the difference between them. springbeanscope-xgoal

    2. Project Structure

    springbeanscope-project-structure
  • Customer and Name are Classes for Java Objects.
  • SpringBeanScopeApplication is SpringBootApplication that includes function main to get Beans and run commands to illustrate example.
  • bean.xml contains all important bean configuration.

    3. Step to do

  • Create Spring Boot project
  • Create DataModels
  • Create Spring Bean Configuration File
  • Add commands to SpringBootApplication Class
  • Run Spring Boot Application & Enjoy Result

    III. Practice

    1. Create Spring Boot project

    Open Spring Tool Suite, on Menu, choose File -> New -> Spring Starter Project, then fill each fields: springbeanscope-startproj

Click Next and Finish. Spring Boot project will be created successfully.

https://grokonez.com/spring-framework/spring-bean-scopes-singleton-prototype

Spring Bean Scopes – Singleton and Prototype

Bình luận


White
{{ comment.user.name }}
Bỏ hay Hay
{{comment.like_count}}
Male avatar
{{ comment_error }}
Hủy
   

Hiển thị thử

Chỉnh sửa

Male avatar

loveprogramming

447 bài viết.
78 người follow
Kipalog
{{userFollowed ? 'Following' : 'Follow'}}
Cùng một tác giả
Male avatar
1 0
Tutorial Link: (Link) (Ảnh) Django is a Pythonbased free and opensource web framework that follows the modeltemplateview architectural pattern. A...
loveprogramming viết 6 tháng trước
1 0
Male avatar
1 0
https://loizenai.com/angular11nodejspostgresqlcrudexample/ Angular 11 Node.js PostgreSQL Crud Example (Ảnh) Tutorial: “Angular 11 Node.js Postg...
loveprogramming viết 5 tháng trước
1 0
Male avatar
1 0
Angular Spring Boot jwt Authentication Example Github https://loizenai.com/angularspringbootjwt/ (Ảnh) Tutorial: ” Angular Spring Boot jwt Authe...
loveprogramming viết 5 tháng trước
1 0
Bài viết liên quan
Male avatar
0 0
How to implement Singleton in Node.js https://grokonez.com/nodejs/howtoimplementsingletoninnodejsexample Singleton is object that can have only a...
loveprogramming viết 1 tháng trước
0 0
Male avatar
0 0
https://grokonez.com/kotlin/kotlinsingletonobjectdeclaration Kotlin Singleton with Object Declaration In object oriented programming, there is a ...
loveprogramming viết 7 ngày trước
0 0
{{like_count}}

kipalog

{{ comment_count }}

bình luận

{{liked ? "Đã kipalog" : "Kipalog"}}


Male avatar
{{userFollowed ? 'Following' : 'Follow'}}
447 bài viết.
78 người follow

 Đầu mục bài viết

Vẫn còn nữa! x

Kipalog vẫn còn rất nhiều bài viết hay và chủ đề thú vị chờ bạn khám phá!