-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
67 changed files
with
1,132 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
# Compiled class file | ||
*.class | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
# Log file | ||
*.log | ||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
# BlueJ files | ||
*.ctxt | ||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
### VS Code ### | ||
.vscode/ | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
.mvn/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
# azb-api-client-spring-boot-starter | ||
Spring boot starter client to consume azb-api | ||
# Spring Boot Starter to consume azb-api | ||
|
||
## Introduction | ||
|
||
This repository is for Spring Boot Starters of azb-api. | ||
|
||
## Client library | ||
|
||
Simply add the following dependency to your project's `pom.xml` will enable you to use the `RestClient` class. | ||
|
||
```xml | ||
<dependency> | ||
<groupId>org.azbuilder.api.spring.starter</groupId> | ||
<artifactId>api-client-spring-boot-starter</artifactId> | ||
<version>0.0.1</version> | ||
</dependency> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
.mvn/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.4.3</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>org.azbuilder.api.spring.autoconfigure</groupId> | ||
<artifactId>api-client-spring-boot-autoconfigure</artifactId> | ||
<version>${revision}</version> | ||
<name>api-client-spring-boot-autoconfigure</name> | ||
<description>Demo project for Spring Boot</description> | ||
<properties> | ||
<java.version>11</java.version> | ||
<spring-cloud.version>2020.0.2</spring-cloud.version> | ||
<gson.version>2.8.6</gson.version> | ||
<feign.version>11.1</feign.version> | ||
<okhttp.version>4.9.1</okhttp.version> | ||
<revision>0.0.1</revision> | ||
<maven.deploy.skip>false</maven.deploy.skip> | ||
</properties> | ||
|
||
<distributionManagement> | ||
<repository> | ||
<id>github</id> | ||
<name>GitHub Packages</name> | ||
<url>https://maven.pkg.github.com/AzBuilder/azb-api-client-spring-boot-starter</url> | ||
</repository> | ||
</distributionManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.azbuilder.api.client</groupId> | ||
<artifactId>api-client</artifactId> | ||
<version>${revision}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.github.openfeign</groupId> | ||
<artifactId>feign-gson</artifactId> | ||
<version>${feign.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.github.openfeign</groupId> | ||
<artifactId>feign-slf4j</artifactId> | ||
<version>${feign.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.github.openfeign</groupId> | ||
<artifactId>feign-okhttp</artifactId> | ||
<version>${feign.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
36 changes: 36 additions & 0 deletions
36
...ure/src/main/java/org/azbuilder/api/spring/autoconfigure/RestClientAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.azbuilder.api.spring.autoconfigure; | ||
|
||
import feign.Feign; | ||
import feign.okhttp.OkHttpClient; | ||
import org.azbuilder.api.client.RestClient; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import feign.slf4j.Slf4jLogger; | ||
import feign.Logger; | ||
import feign.gson.GsonDecoder; | ||
import feign.gson.GsonEncoder; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties(RestClientProperties.class) | ||
@ConditionalOnMissingBean(RestClient.class) | ||
public class RestClientAutoConfiguration { | ||
|
||
@Autowired | ||
private RestClientProperties restClientProperties; | ||
|
||
@Bean | ||
public RestClient terraformClient(RestClientProperties restClientProperties) { | ||
RestClient restClient = Feign.builder() | ||
.encoder(new GsonEncoder()) | ||
.decoder(new GsonDecoder()) | ||
.client( new OkHttpClient()) | ||
//.logger(new Slf4jLogger()) | ||
//.logLevel(Logger.Level.BASIC) | ||
|
||
.target(RestClient.class, restClientProperties.getUrl()); | ||
return restClient; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...oconfigure/src/main/java/org/azbuilder/api/spring/autoconfigure/RestClientProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.azbuilder.api.spring.autoconfigure; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.PropertySource; | ||
import org.springframework.context.annotation.PropertySources; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Getter | ||
@Setter | ||
@PropertySources({ | ||
@PropertySource(value = "classpath:application.properties", ignoreResourceNotFound = true), | ||
@PropertySource(value = "classpath:application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) | ||
}) | ||
@ConfigurationProperties(prefix = "org.azbuilder.api") | ||
public class RestClientProperties { | ||
private String url; | ||
} |
2 changes: 2 additions & 0 deletions
2
api-client-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||
org.azbuilder.api.spring.autoconfigure.RestClientAutoConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.4.3</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>org.azbuilder.api.client.sample</groupId> | ||
<artifactId>api-client-starter-sample</artifactId> | ||
<version>${revision}</version> | ||
<name>api-client-starter-sample</name> | ||
<description>Demo project for Spring Boot</description> | ||
<properties> | ||
<java.version>11</java.version> | ||
<revision>0.0.1</revision> | ||
<maven.deploy.skip>true</maven.deploy.skip> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.azbuilder.api.spring.starter</groupId> | ||
<artifactId>api-client-spring-boot-starter</artifactId> | ||
<version>${revision}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
...mple/src/main/java/org/azbuilder/api/client/sample/ApiClientStarterSampleApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.azbuilder.api.client.sample; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class ApiClientStarterSampleApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ApiClientStarterSampleApplication.class, args); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
api-client-spring-boot-starter-sample/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
22 changes: 22 additions & 0 deletions
22
...src/test/java/org/azbuilder/api/client/sample/ApiClientStarterSampleApplicationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.azbuilder.api.client.sample; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import org.azbuilder.api.client.RestClient; | ||
|
||
@SpringBootTest | ||
class ApiClientStarterSampleApplicationTests { | ||
|
||
@Autowired | ||
RestClient restClient; | ||
|
||
@Test | ||
void contextLoads() { | ||
assertNotNull(restClient); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
api-client-spring-boot-starter-sample/src/test/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.azbuilder.api.url=http://localhost:8080 |
Oops, something went wrong.