Skip to content

Commit 19225dc

Browse files
committed
moved to core folder
1 parent 4b3f52e commit 19225dc

File tree

253 files changed

+8602
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

253 files changed

+8602
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SpringBooot
2+
<i>Here you will finds examples of spring boot concept</i>
3+
<ol>
4+
<li> <a href="/SpringFirstAppManually">Spring Boot FirstApp </a> </li>
5+
<li> <a href="/CommandLineRunners">Command Line Runners </a> </li>
6+
<li> <a href="/ProjectLombokExample">Project Lombok Example </a> </li>
7+
<li> <a href="/ProjectLombokConstrucors">Project Lombok Constructors </a> </li>
8+
<li> <a href="/SpringBootProfiles-code_change-Example">SpringBootProfiles-code_change-Example </a> </li>
9+
<li> <a href="/SpringBootProfiles-multiple-propertyFile">SpringBootProfiles-multiple-propertyFile</a> </li>
10+
<li> <a href="/SpringBootProfiles-multiple-property-OneYml">SpringBootProfiles-multiple-property-OneYml </a> </li>
11+
<li> <a href="/SpringBootProfiles-property_file-Example">SpringBootProfiles-property_file-Example</a> </li>
12+
<li> <a href="/SpringBootProfiles-service-based-multiple-profiles">SpringBootProfiles-service-based-multiple-profiles </a>
13+
<li> <a href="/SpringBootStarter-SpringContainer">SpringBootStarter-SpringContainer</a> </li>
14+
<li> <a href="/SpringBootStarter-othside-basePackage">SpringBootStarter-othside-basePackage</a> </li>
15+
<li> <a href="/SpringBootStarter-Configuration_Component">SpringBootStarter-Configuration_Component</a> </li>
16+
<li> <a href="/SpringBootStarter-autoLoadConfiguration">SpringBootStarter-autoLoadConfiguration</a> </li>
17+
</li>
18+
</ol>
19+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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>org.sathyatech</groupId>
4+
<artifactId>ApplicationRunners</artifactId>
5+
<version>0.0.1-SNAPSHOT</version>
6+
7+
<!-- 1. Parent Project -->
8+
<parent>
9+
<groupId>org.springframework.boot</groupId>
10+
<artifactId>spring-boot-starter-parent</artifactId>
11+
<version>2.1.4.RELEASE</version>
12+
</parent>
13+
<!-- 2. Properties -->
14+
<properties>
15+
<java.version>1.8</java.version>
16+
</properties>
17+
18+
<!-- 3. Dependencies -->
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.springframework.boot</groupId>
22+
<artifactId>spring-boot-starter</artifactId>
23+
</dependency>
24+
</dependencies>
25+
26+
<!-- 4. build plugins -->
27+
<build>
28+
<plugins>
29+
<plugin>
30+
<groupId>org.springframework.boot</groupId>
31+
<artifactId>spring-boot-maven-plugin</artifactId>
32+
</plugin>
33+
</plugins>
34+
</build>
35+
36+
37+
</project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.app;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
/*
7+
for giving input right click on app > Run configurations > arguments tab > provide arguments seprate by space
8+
9+
10+
--profile=dev clean start --profile=qa --db=oracle --db=mysql install --model=active
11+
*/
12+
13+
@SpringBootApplication
14+
public class MyStarter {
15+
16+
public static void main(String[] args) {
17+
18+
SpringApplication.run(MyStarter.class, args);
19+
System.out.println("hii");
20+
}
21+
22+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.app.runners;
2+
3+
import java.util.List;
4+
import java.util.Set;
5+
6+
import org.springframework.boot.ApplicationArguments;
7+
import org.springframework.boot.ApplicationRunner;
8+
import org.springframework.stereotype.Component;
9+
10+
// the difference between CLR and AR is that AR store arguments (optional and non optional) as
11+
// optional - Map<String, List<String> , non-optional - List<String>
12+
13+
14+
@Component
15+
public class ConsoleRunner implements ApplicationRunner{
16+
17+
@Override
18+
public void run(ApplicationArguments args) throws Exception {
19+
20+
// all optional keys
21+
22+
Set<String> optionKeys = args.getOptionNames();
23+
System.out.println(optionKeys);
24+
25+
// all non-optional keys
26+
27+
List<String> nonOptionKeys = args.getNonOptionArgs();
28+
System.out.println(nonOptionKeys);
29+
30+
// all arguments
31+
32+
String[] arg = args.getSourceArgs();
33+
System.out.println(arg);
34+
35+
// check one key related value
36+
List<String> list = args.getOptionValues("profile");
37+
System.out.println(list);
38+
39+
//check key exist
40+
41+
System.out.println(args.containsOption("nature"));
42+
System.out.println(args.containsOption("db"));
43+
44+
45+
}
46+
47+
}
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: ApplicationRunners
3+
Implementation-Version: 0.0.1-SNAPSHOT
4+
Built-By: The_Incredible_Srv
5+
Implementation-Vendor-Id: org.sathyatech
6+
Build-Jdk: 1.8.0_201
7+
Implementation-URL: https://projects.spring.io/spring-boot/#/spring-bo
8+
ot-starter-parent/ApplicationRunners
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+
#Mon Jun 03 17:05:45 IST 2019
3+
version=0.0.1-SNAPSHOT
4+
groupId=org.sathyatech
5+
m2e.projectName=ApplicationRunners
6+
m2e.projectLocation=C\:\\Users\\The_Incredible_Srv\\Documents\\spring\\springBoot\\ApplicationRunners
7+
artifactId=ApplicationRunners
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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>org.sathyatech</groupId>
4+
<artifactId>ApplicationRunners</artifactId>
5+
<version>0.0.1-SNAPSHOT</version>
6+
7+
<!-- 1. Parent Project -->
8+
<parent>
9+
<groupId>org.springframework.boot</groupId>
10+
<artifactId>spring-boot-starter-parent</artifactId>
11+
<version>2.1.4.RELEASE</version>
12+
</parent>
13+
<!-- 2. Properties -->
14+
<properties>
15+
<java.version>1.8</java.version>
16+
</properties>
17+
18+
<!-- 3. Dependencies -->
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.springframework.boot</groupId>
22+
<artifactId>spring-boot-starter</artifactId>
23+
</dependency>
24+
</dependencies>
25+
26+
<!-- 4. build plugins -->
27+
<build>
28+
<plugins>
29+
<plugin>
30+
<groupId>org.springframework.boot</groupId>
31+
<artifactId>spring-boot-maven-plugin</artifactId>
32+
</plugin>
33+
</plugins>
34+
</build>
35+
36+
37+
</project>
Binary file not shown.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>org.sathya</groupId>
6+
<artifactId>SpringFirstAppManually</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
9+
10+
<!-- 1. Parent Project -->
11+
<parent>
12+
<groupId>org.springframework.boot</groupId>
13+
<artifactId>spring-boot-starter-parent</artifactId>
14+
<version>2.1.5.RELEASE</version>
15+
</parent>
16+
<!-- 2. Properties -->
17+
<properties>
18+
<java.version>1.8</java.version>
19+
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
20+
</properties>
21+
22+
<!-- 3. Dependencies -->
23+
<dependencies>
24+
<dependency>
25+
<groupId>org.springframework.boot</groupId>
26+
<artifactId>spring-boot-starter</artifactId>
27+
</dependency>
28+
</dependencies>
29+
30+
<!-- 4. build plugins -->
31+
<build>
32+
<plugins>
33+
<plugin>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-maven-plugin</artifactId>
36+
</plugin>
37+
</plugins>
38+
</build>
39+
40+
41+
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.app;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
7+
// starting point of application
8+
9+
10+
@SpringBootApplication // consist of @Component ,@Configuration ...
11+
public class StarterInput {
12+
13+
public static void main(String[] args) {
14+
15+
System.out.println(" from starter ");
16+
17+
SpringApplication.run(StarterInput.class, args);
18+
}
19+
20+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.app.runners;
2+
3+
4+
import java.util.Arrays;
5+
6+
import org.springframework.boot.CommandLineRunner;
7+
import org.springframework.core.Ordered;
8+
import org.springframework.stereotype.Component;
9+
10+
11+
/* there are two runners in spring boot
12+
* 1. CommandLineRunner (legacy runner)
13+
* 2.ApplicationRunner
14+
*
15+
* runners are to execute java login once on starting .
16+
* We can hae multiple runners and they are executed according to naming convention .
17+
* we can also define naming using @Order(int) or implementing Order interface .
18+
*
19+
* */
20+
21+
22+
@Component // bvs run method is instance method so obj needed to call it ,that will be created by spring container
23+
public class RunnerWithInput implements CommandLineRunner{
24+
25+
@Override
26+
public void run(String... args) throws Exception {
27+
28+
System.out.println("from runner ");
29+
30+
System.out.println("inputs : "+Arrays.asList(args));
31+
32+
}
33+
34+
35+
36+
}
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: SpringFirstAppManually
3+
Implementation-Version: 0.0.1-SNAPSHOT
4+
Built-By: The_Incredible_Srv
5+
Implementation-Vendor-Id: org.sathya
6+
Build-Jdk: 1.8.0_201
7+
Implementation-URL: https://projects.spring.io/spring-boot/#/spring-bo
8+
ot-starter-parent/SpringFirstAppManually
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+
#Mon Jun 03 10:40:28 IST 2019
3+
version=0.0.1-SNAPSHOT
4+
groupId=org.sathya
5+
m2e.projectName=CommandLineRunnerWithInputs
6+
m2e.projectLocation=C\:\\Users\\The_Incredible_Srv\\Documents\\spring\\springBoot\\CommandLineRunnerWithInputs
7+
artifactId=SpringFirstAppManually
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>org.sathya</groupId>
6+
<artifactId>SpringFirstAppManually</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
9+
10+
<!-- 1. Parent Project -->
11+
<parent>
12+
<groupId>org.springframework.boot</groupId>
13+
<artifactId>spring-boot-starter-parent</artifactId>
14+
<version>2.1.5.RELEASE</version>
15+
</parent>
16+
<!-- 2. Properties -->
17+
<properties>
18+
<java.version>1.8</java.version>
19+
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
20+
</properties>
21+
22+
<!-- 3. Dependencies -->
23+
<dependencies>
24+
<dependency>
25+
<groupId>org.springframework.boot</groupId>
26+
<artifactId>spring-boot-starter</artifactId>
27+
</dependency>
28+
</dependencies>
29+
30+
<!-- 4. build plugins -->
31+
<build>
32+
<plugins>
33+
<plugin>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-maven-plugin</artifactId>
36+
</plugin>
37+
</plugins>
38+
</build>
39+
40+
41+
</project>
Binary file not shown.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>org.sathya</groupId>
6+
<artifactId>SpringFirstAppManually</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
9+
10+
<!-- 1. Parent Project -->
11+
<parent>
12+
<groupId>org.springframework.boot</groupId>
13+
<artifactId>spring-boot-starter-parent</artifactId>
14+
<version>2.1.5.RELEASE</version>
15+
</parent>
16+
<!-- 2. Properties -->
17+
<properties>
18+
<java.version>1.8</java.version>
19+
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
20+
</properties>
21+
22+
<!-- 3. Dependencies -->
23+
<dependencies>
24+
<dependency>
25+
<groupId>org.springframework.boot</groupId>
26+
<artifactId>spring-boot-starter</artifactId>
27+
</dependency>
28+
</dependencies>
29+
30+
<!-- 4. build plugins -->
31+
<build>
32+
<plugins>
33+
<plugin>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-maven-plugin</artifactId>
36+
</plugin>
37+
</plugins>
38+
</build>
39+
40+
41+
</project>

0 commit comments

Comments
 (0)