Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
60 changes: 29 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# springboot-java8
The project is made on spring boot. The project summarize the new features present in Java 8.
It contain list of harcoded topics list. You can call the apis's with POSTMAN to add,delete,update Topic list
In addition, it uses
1) Java 8 NIO methods
A Spring Boot project demonstrating Java features including streams, lambdas, NIO, and more.
It contains a list of hardcoded topics. You can call the APIs with POSTMAN to add, delete, update the Topic list.
In addition, it uses:
1) Java NIO methods
2) String operations
3) Stream operations
4) IntStream functions
Expand All @@ -11,14 +11,32 @@ In addition, it uses
7) Optional datatype
8) Foreach loops
9) Default and Static methods in interface
10) Java 8 LocalDateTime API
10) Java LocalDateTime API
11) Pattern



## Requirements

- **Java 21**
- **Spring Boot 3.4.5**
- **Maven 3.9.9** (via Maven Wrapper) or **Gradle 8.12** (via Gradle Wrapper)

## Getting Started
1) Download or clone the project with link
(https://github.com/RehmanMuradAli/springboot-java8/)

### Build & Run with Maven
```bash
./mvnw clean package
java -jar target/gs-spring-boot-0.1.0.jar
```

### Build & Run with Gradle
```bash
./gradlew build
java -jar build/libs/gs-spring-boot-0.1.0.jar
```

The application starts on `http://localhost:8080`.

## Available API's

Expand Down Expand Up @@ -67,41 +85,22 @@ File Operations on Topic List
```
GET /topic/file/operation
```
Java 8 Date Time example
Java Date Time example
```
GET /datetime
```



### Prerequisites

1) Java sdk
2) POSTMAN

### Installing



```
1) Download or clone
2) Import the project
3) Run on location machine
4) Open Postman, to call API's ( localhost:8080 )
```


## Helpful Links
Spring:

https://spring.io/guides

Java 8:
Java:

http://www.baeldung.com/java-8-functional-interfaces

http://winterbe.com/posts/2015/05/22/java8-concurrency-tutorial-atomic-concurrent-map-examples/

https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html

http://winterbe.com/posts/2014/07/31/java8-stream-tutorial-examples/
Expand All @@ -126,9 +125,8 @@ https://dzone.com/articles/java-8-friday-goodies-new-new
## Built With

* [Maven](https://maven.apache.org/) - Dependency Management
* [Spring Boot](https://spring.io/projects/spring-boot) - Application Framework

## Authors

* **Rehman Murad Ali**


* **Rehman Murad Ali**
12 changes: 7 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.2.RELEASE")
classpath("org.springframework.boot:spring-boot-gradle-plugin:3.4.5")
}
}

Expand All @@ -22,11 +22,13 @@ repositories {
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 21
targetCompatibility = 21

dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("junit:junit")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-jdbc")
runtimeOnly("com.h2database:h2")
testImplementation("junit:junit")
}

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
11 changes: 3 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,16 @@

<groupId>org.springframework</groupId>
<artifactId>gs-spring-boot</artifactId>
<packaging>pom</packaging>
<packaging>jar</packaging>
<version>0.1.0</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<version>3.4.5</version>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand All @@ -35,7 +30,7 @@
</dependencies>

<properties>
<java.version>1.8</java.version>
<java.version>21</java.version>
</properties>


Expand Down
25 changes: 1 addition & 24 deletions src/main/java/hello/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@
import java.util.stream.Collectors;

import hello.model.Customer;
import hello.model.Quote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
public class Application implements CommandLineRunner {
Expand All @@ -34,25 +30,6 @@ public static void main(String[] args) {
for (String beanName : beanNames) {
System.out.println(beanName);
}

RestTemplate restTemplate = new RestTemplate();
Quote quote = restTemplate.getForObject("http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
log.info(quote.toString());
}


@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}

@Bean
public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
return args -> {
Quote quote = restTemplate.getForObject(
"http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
log.info(quote.toString());
};
}


Expand All @@ -63,7 +40,7 @@ public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
public void run(String... args) throws Exception {
log.info("Creating tables");

jdbcTemplate.execute("DROP TABLE customers IF EXISTS");
jdbcTemplate.execute("DROP TABLE IF EXISTS customers");
jdbcTemplate.execute("CREATE TABLE customers(id SERIAL, first_name VARCHAR(255), last_name VARCHAR(255))");

// Split up the array of whole names into an array of first/last names
Expand Down