Skip to content

Commit 7d9da2a

Browse files
author
InDepthTutorial
committed
Types of Beans in Spring
1 parent 74d2e24 commit 7d9da2a

File tree

14 files changed

+195
-0
lines changed

14 files changed

+195
-0
lines changed

Singleton-Prototype-Demo/.classpath

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15+
<attributes>
16+
<attribute name="optional" value="true"/>
17+
<attribute name="maven.pomderived" value="true"/>
18+
<attribute name="test" value="true"/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
22+
<attributes>
23+
<attribute name="maven.pomderived" value="true"/>
24+
<attribute name="test" value="true"/>
25+
</attributes>
26+
</classpathentry>
27+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
28+
<attributes>
29+
<attribute name="maven.pomderived" value="true"/>
30+
</attributes>
31+
</classpathentry>
32+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
33+
<attributes>
34+
<attribute name="maven.pomderived" value="true"/>
35+
</attributes>
36+
</classpathentry>
37+
<classpathentry kind="output" path="target/classes"/>
38+
</classpath>

Singleton-Prototype-Demo/.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Singleton-Prototype-Demo</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
3+
encoding//src/main/resources=UTF-8
4+
encoding//src/test/java=UTF-8
5+
encoding//src/test/resources=UTF-8
6+
encoding/<project>=UTF-8
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.compliance=1.8
5+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
6+
org.eclipse.jdt.core.compiler.release=disabled
7+
org.eclipse.jdt.core.compiler.source=1.8
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1

Singleton-Prototype-Demo/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.idt</groupId>
4+
<artifactId>Singleton-Prototype-Demo</artifactId>
5+
<version>0.0.1-SNAPSHOT</version>
6+
<name>Singleton-Prototype-Demo</name>
7+
<parent>
8+
<groupId>org.springframework.boot</groupId>
9+
<artifactId>spring-boot-starter-parent</artifactId>
10+
<version>2.1.1.RELEASE</version>
11+
</parent>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter</artifactId>
17+
</dependency>
18+
</dependencies>
19+
</project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.idt;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.context.ApplicationContext;
6+
7+
import com.idt.beans.TestBean;
8+
9+
@SpringBootApplication
10+
public class AppStarter {
11+
12+
public static void main(String[] args) {
13+
ApplicationContext ctx = SpringApplication.run(AppStarter.class, args);
14+
System.out.println("Application started, obtaining TestBean...");
15+
16+
TestBean tb1=(TestBean)ctx.getBean("tb");
17+
TestBean tb2=(TestBean)ctx.getBean("tb");
18+
System.out.println(tb1==tb2);
19+
}
20+
21+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.idt.beans;
2+
3+
import org.springframework.context.annotation.Scope;
4+
import org.springframework.stereotype.Component;
5+
6+
@Scope("prototype")
7+
@Component("tb")
8+
public class TestBean {
9+
10+
TestBean(){
11+
System.out.println("TestBean bean is created.");
12+
}
13+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/com/
2+
/META-INF/
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Manifest-Version: 1.0
2+
Implementation-Title: Singleton-Prototype-Demo
3+
Implementation-Version: 0.0.1-SNAPSHOT
4+
Built-By: In-Depth
5+
Implementation-Vendor-Id: com.idt
6+
Build-Jdk: 1.8.0_60
7+
Implementation-URL: https://projects.spring.io/spring-boot/#/spring-bo
8+
ot-starter-parent/Singleton-Prototype-Demo
9+
Created-By: Maven Integration for Eclipse
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Generated by Maven Integration for Eclipse
2+
#Sun Jun 09 21:39:48 IST 2019
3+
version=0.0.1-SNAPSHOT
4+
groupId=com.idt
5+
m2e.projectName=Singleton-Prototype-Demo
6+
m2e.projectLocation=D\:\\Practice\\Spring\\Spring Boot\\In-Depth\\Singleton-Prototype-Demo
7+
artifactId=Singleton-Prototype-Demo
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.idt</groupId>
4+
<artifactId>Singleton-Prototype-Demo</artifactId>
5+
<version>0.0.1-SNAPSHOT</version>
6+
<name>Singleton-Prototype-Demo</name>
7+
<parent>
8+
<groupId>org.springframework.boot</groupId>
9+
<artifactId>spring-boot-starter-parent</artifactId>
10+
<version>2.1.1.RELEASE</version>
11+
</parent>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter</artifactId>
17+
</dependency>
18+
</dependencies>
19+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Generated by Maven Integration for Eclipse
2+
#Sun Jun 09 21:06:41 IST 2019
3+
version=0.0.1-SNAPSHOT
4+
groupId=com.idt
5+
m2e.projectName=Singleton-Prototype-Demo
6+
m2e.projectLocation=D\:\\Practice\\Spring\\Spring Boot\\In-Depth\\Singleton-Prototype-Demo
7+
artifactId=Spring-Boot-Demo
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.idt</groupId>
4+
<artifactId>Spring-Boot-Demo</artifactId>
5+
<version>0.0.1-SNAPSHOT</version>
6+
<name>Spring-Boot-Demo</name>
7+
<parent>
8+
<groupId>org.springframework.boot</groupId>
9+
<artifactId>spring-boot-starter-parent</artifactId>
10+
<version>2.1.1.RELEASE</version>
11+
</parent>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter</artifactId>
17+
</dependency>
18+
</dependencies>
19+
</project>

0 commit comments

Comments
 (0)