Skip to content

Commit

Permalink
Fixing logs; fixing Swagger dependency update to 2.10.5; fixing Sprin…
Browse files Browse the repository at this point in the history
…g Admin Client configuration.
  • Loading branch information
Mariana Azevedo committed Jul 30, 2020
1 parent c9254a3 commit a7402dd
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: java -jar -Dspring.profiles.active=prod -Dserver.port=$PORT target/financial-java-api-3.0.1-SNAPSHOT.jar
web: java -jar -Dspring.profiles.active=prod -Dserver.port=$PORT target/financial-java-api-3.0.2-SNAPSHOT.jar
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,13 @@ This project was developed with:

* **Java 11 (Java Development Kit - JDK: 11.0.7)**
* **Spring Boot 2.3.0**
* **Spring Admin Client 2.2.3**
* **Maven**
* **JUnit 5**
* **Surfire**
* **PostgreSQL 12**
* **Flyway 6.4.1**
* **Swagger 2.9.2**
* **Swagger 2.10.5**
* **Model Mapper 2.3.8**
* **Heroku**
* **EhCache**
Expand All @@ -178,7 +179,7 @@ The API also was developed to run with an `jar`. In order to generate this `jar`
mvn package
```

It will clean, compile and generate a `jar` at target directory, e.g. `financial-java-api-3.0.1-SNAPSHOT.jar`
It will clean, compile and generate a `jar` at target directory, e.g. `financial-java-api-3.0.2-SNAPSHOT.jar`

### Execution

Expand Down Expand Up @@ -216,7 +217,7 @@ mvn integration-test
In order to run the API, run the jar simply as following:

```bash
java -jar financial-java-api-3.0.1-SNAPSHOT.jar --spring.profiles.active=prod
java -jar financial-java-api-3.0.2-SNAPSHOT.jar --spring.profiles.active=prod
```

or
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>io.github.mariazevedo88</groupId>
<artifactId>financial-java-api</artifactId>
<version>3.0.1-SNAPSHOT</version>
<version>3.0.2-SNAPSHOT</version>
<packaging>jar</packaging>

<name>financial-java-api</name>
Expand All @@ -30,7 +30,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<version>2.3.2.RELEASE</version>
<relativePath/>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import javax.validation.Valid;

import org.modelmapper.ModelMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;
Expand Down Expand Up @@ -39,19 +37,19 @@
import io.github.mariazevedo88.financialjavaapi.service.transaction.TransactionService;
import io.github.mariazevedo88.financialjavaapi.util.FinancialApiUtil;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;

/**
* SpringBoot RestController that creates all service endpoints related to the transaction.
*
* @author Mariana Azevedo
* @since 08/09/2019
*/
@Log4j2
@RestController
@RequestMapping("/financial/v1/transactions")
public class TransactionController {

private static final Logger logger = LoggerFactory.getLogger(TransactionController.class);

private TransactionService transactionService;

@Autowired
Expand Down Expand Up @@ -220,7 +218,7 @@ public ResponseEntity<Response<List<TransactionDTO>>> findAll(@RequestHeader(val
try {
createSelfLinkInCollections(apiVersion, apiKey, dto);
} catch (TransactionNotFoundException e) {
logger.error("There are no transactions registered in the database.");
log.error("There are no transactions registered in the database.");
}
});

Expand Down Expand Up @@ -274,7 +272,7 @@ public ResponseEntity<Response<List<TransactionDTO>>> findByNsu(@RequestHeader(v
try {
createSelfLinkInCollections(apiVersion, apiKey, dto);
} catch (TransactionNotFoundException e) {
logger.error("There are no transactions registered with the nsu=" + transactionNSU);
log.error("There are no transactions registered with the nsu=" + transactionNSU);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,27 @@

import org.ehcache.event.CacheEvent;
import org.ehcache.event.CacheEventListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import lombok.extern.log4j.Log4j2;

/**
* Class that implements an event logger to show cache creation and expiration
* in the API.
*
* @author Mariana Azevedo
* @since 11/06/2020
*/
@Log4j2
@Component
public class CacheEventLogger implements CacheEventListener<Object, Object> {

private static final Logger logger = LoggerFactory.getLogger(CacheEventLogger.class);

/**
* @see CacheEventListener#onEvent(CacheEvent)
*/
@Override
public void onEvent(CacheEvent<? extends Object, ? extends Object> cacheEvent) {
logger.info("Cache event {} for item with key {}. Old value = {}, New value = {}", cacheEvent.getType(),
log.info("Cache event {} for item with key {}. Old value = {}, New value = {}", cacheEvent.getType(),
cacheEvent.getKey(), cacheEvent.getOldValue(), cacheEvent.getNewValue());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public class FinancialApiConfiguration {
public LinkDiscoverers discoverers() {
List<LinkDiscoverer> plugins = new ArrayList<>();
plugins.add(new CollectionJsonLinkDiscoverer());
return new LinkDiscoverers(SimplePluginRegistry.create(plugins));
return new LinkDiscoverers(SimplePluginRegistry.of(plugins));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
* Class that implements the necessary settings for using Swagger as an API documentation tool.
Expand All @@ -20,7 +20,7 @@
*/
@Configuration
@Profile({"dev"})
@EnableSwagger2
@EnableSwagger2WebMvc
public class SwaggerConfiguration {

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pagination.items_per_page=10
jwt.secret=oioqowepjsjdasd!$%mknfskdnf090192019
jwt.expiration=6000

api.version=2020-06-14
api.version=2020-07-29
api.key="FX001-FREE"

#Enable response compression
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spring.cache.jcache.config=classpath:cache/ehcache.xml
spring.mvc.throw-exception-if-no-handler-found=true
spring.mvc.resources.add-mappings=false

api.version=2020-06-14
api.version=2020-07-29
api.key="FX001-FREE"

#Enable response compression
Expand Down
10 changes: 7 additions & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pagination.items_per_page=10
jwt.secret=qweernadnamdn19820918209!#ajhad
jwt.expiration=3600

api.version=2020-06-14
api.version=2020-07-29
api.key="FX001-FREE"

#Enable response compression
Expand All @@ -33,8 +33,12 @@ server.compression.min-response-size=2048
#Mime types that should be compressed
server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,application/javascript,text/css

#Configuring Spring Boot Admin Server
spring.boot.admin.client.url=http://localhost:9090
#Configuring Spring Boot Admin Client
server.url=http://localhost
server.admin.port=9090
server.client.port=8080
spring.boot.admin.client.url=${server.url}:${server.admin.port}
spring.boot.admin.client.instance.serviceBaseUrl=${server.url}:${server.client.port}

management.endpoints.web.base-path=/manage
management.endpoints.web.exposure.include=*
Expand Down

0 comments on commit a7402dd

Please sign in to comment.