This commit is contained in:
Loredana
2020-07-20 16:18:51 +03:00
131 changed files with 904 additions and 148 deletions
@@ -7,7 +7,6 @@ This module contains articles about core Java input/output(IO) APIs.
- [A Guide to the Java FileReader Class](https://www.baeldung.com/java-filereader)
- [The Java File Class](https://www.baeldung.com/java-io-file)
- [Java FileWriter](https://www.baeldung.com/java-filewriter)
- [Differences Between the Java WatchService API and the Apache Commons IO Monitor Library](https://www.baeldung.com/java-watchservice-vs-apache-commons-io-monitor-library)
- [Comparing getPath(), getAbsolutePath(), and getCanonicalPath() in Java](https://www.baeldung.com/java-path)
- [Quick Use of FilenameFilter](https://www.baeldung.com/java-filename-filter)
- [Guide to BufferedReader](https://www.baeldung.com/java-buffered-reader)
+1
View File
@@ -13,3 +13,4 @@ This module contains articles about Apache Commons libraries.
- [Apache Commons BeanUtils](https://www.baeldung.com/apache-commons-beanutils)
- [Histograms with Apache Commons Frequency](https://www.baeldung.com/apache-commons-frequency)
- [An Introduction to Apache Commons Lang 3](https://www.baeldung.com/java-commons-lang-3)
- [Differences Between the Java WatchService API and the Apache Commons IO Monitor Library](https://www.baeldung.com/java-watchservice-vs-apache-commons-io-monitor-library)
+6
View File
@@ -57,6 +57,11 @@
<artifactId>xchart</artifactId>
<version>${xchart-version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${common-io.version}</version>
</dependency>
</dependencies>
<properties>
@@ -68,6 +73,7 @@
<commons.dbutils.version>1.6</commons.dbutils.version>
<xchart-version>3.5.2</xchart-version>
<common-math3.version>3.6.1</common-math3.version>
<common-io.version>2.5</common-io.version>
</properties>
</project>
+1
View File
@@ -31,6 +31,7 @@
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${rest-assured.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -0,0 +1,23 @@
package com.baeldung.statmentVsPreparedstatment;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DatasourceFactory {
private Connection connection;
public Connection getConnection() throws ClassNotFoundException, SQLException {
Class.forName("org.h2.Driver");
connection = DriverManager.getConnection("jdbc:h2:mem:db_basic", "SA", "");
connection.setAutoCommit(false);
return connection;
}
public boolean createTables() throws SQLException {
String query = "create table if not exists PERSONS (ID INT, NAME VARCHAR(45))";
return connection.createStatement().executeUpdate(query) == 0;
}
}
@@ -0,0 +1,42 @@
package com.baeldung.statmentVsPreparedstatment;
import java.util.Objects;
public class PersonEntity {
private int id;
private String name;
public PersonEntity(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
PersonEntity that = (PersonEntity) o;
return id == that.id && Objects.equals(name, that.name);
}
@Override public int hashCode() {
return Objects.hash(id, name);
}
}
@@ -0,0 +1,88 @@
package com.baeldung.statmentVsPreparedstatment;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class PreparedStatementPersonDao {
private final Connection connection;
public PreparedStatementPersonDao(Connection connection) {
this.connection = connection;
}
public Optional<PersonEntity> getById(int id) throws SQLException {
String query = "SELECT id, name FROM persons WHERE id = ?";
PreparedStatement preparedStatement = connection.prepareStatement(query);
preparedStatement.setInt(1, id);
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.first()) {
PersonEntity result = new PersonEntity(resultSet.getInt("id"),
resultSet.getString("name"));
return Optional.of(result);
} else {
return Optional.empty();
}
}
public void insert(PersonEntity personEntity) throws SQLException {
String query = "INSERT INTO persons(id, name) VALUES( ?, ?)";
PreparedStatement preparedStatement = connection.prepareStatement(query);
preparedStatement.setInt(1, personEntity.getId());
preparedStatement.setString(2, personEntity.getName());
preparedStatement.executeUpdate();
}
public void insert(List<PersonEntity> personEntities) throws SQLException {
String query = "INSERT INTO persons(id, name) VALUES( ?, ?)";
PreparedStatement preparedStatement = connection.prepareStatement(query);
for (PersonEntity personEntity : personEntities) {
preparedStatement.setInt(1, personEntity.getId());
preparedStatement.setString(2, personEntity.getName());
preparedStatement.addBatch();
}
preparedStatement.executeBatch();
}
public void update(PersonEntity personEntity) throws SQLException {
String query = "UPDATE persons SET name = ? WHERE id = ?";
PreparedStatement preparedStatement = connection.prepareStatement(query);
preparedStatement.setString(1, personEntity.getName());
preparedStatement.setInt(2, personEntity.getId());
preparedStatement.executeUpdate();
}
public void deleteById(int id) throws SQLException {
String query = "DELETE FROM persons WHERE id = ?";
PreparedStatement preparedStatement = connection.prepareStatement(query);
preparedStatement.setInt(1, id);
preparedStatement.executeUpdate();
}
public List<PersonEntity> getAll() throws SQLException {
String query = "SELECT id, name FROM persons";
PreparedStatement preparedStatement = connection.prepareStatement(query);
ResultSet resultSet = preparedStatement.executeQuery();
List<PersonEntity> result = new ArrayList<>();
while (resultSet.next()) {
result.add(new PersonEntity(resultSet.getInt("id"), resultSet.getString("name")));
}
return result;
}
}
@@ -0,0 +1,75 @@
package com.baeldung.statmentVsPreparedstatment;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class StatementPersonDao {
private final Connection connection;
public StatementPersonDao(Connection connection) {
this.connection = connection;
}
public Optional<PersonEntity> getById(int id) throws SQLException {
String query = "SELECT id, name, FROM persons WHERE id = '" + id + "'";
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
if (resultSet.first()) {
PersonEntity result = new PersonEntity(resultSet.getInt("id"),
resultSet.getString("name"));
return Optional.of(result);
} else {
return Optional.empty();
}
}
public void insert(PersonEntity personEntity) throws SQLException {
String query = "INSERT INTO persons(id, name) VALUES(" + personEntity.getId() + ", '"
+ personEntity.getName() + "')";
Statement statement = connection.createStatement();
statement.executeUpdate(query);
}
public void insert(List<PersonEntity> personEntities) throws SQLException {
for (PersonEntity personEntity : personEntities) {
insert(personEntity);
}
}
public void update(PersonEntity personEntity) throws SQLException {
String query = "UPDATE persons SET name = '" + personEntity.getName() + "' WHERE id = "
+ personEntity.getId();
Statement statement = connection.createStatement();
statement.executeUpdate(query);
}
public void deleteById(int id) throws SQLException {
String query = "DELETE FROM persons WHERE id = " + id;
Statement statement = connection.createStatement();
statement.executeUpdate(query);
}
public List<PersonEntity> getAll() throws SQLException {
String query = "SELECT id, name, FROM persons";
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
List<PersonEntity> result = new ArrayList<>();
while (resultSet.next()) {
result.add(new PersonEntity(resultSet.getInt("id"), resultSet.getString("name")));
}
return result;
}
}
@@ -0,0 +1,22 @@
package com.baeldung.statmentVsPreparedstatment;
import org.junit.jupiter.api.Test;
import java.sql.Connection;
import java.sql.SQLException;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
class DatasourceFactoryUnitTest {
@Test
void whenCreateConnectionAndTables_thenConnectionIsOpenAndTableIsCreated()
throws SQLException, ClassNotFoundException {
DatasourceFactory factory = new DatasourceFactory();
Connection connection = factory.getConnection();
assertFalse(connection.isClosed());
assertTrue(factory.createTables());
}
}
@@ -0,0 +1,94 @@
package com.baeldung.statmentVsPreparedstatment;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.*;
class PreparedStatementPersonDaoUnitTest {
private PreparedStatementPersonDao dao;
@BeforeEach
void setup() throws SQLException, ClassNotFoundException {
DatasourceFactory datasourceFactory = new DatasourceFactory();
Connection connection = datasourceFactory.getConnection();
datasourceFactory.createTables();
dao = new PreparedStatementPersonDao(connection);
}
@Test
void whenInsertAPerson_thenItNeverThrowsAnException() {
assertDoesNotThrow(() -> dao.insert(new PersonEntity(1, "john")));
}
@Test
void whenInsertAPersonWithQuoteInText_thenItNeverThrowsAnException() {
assertDoesNotThrow(() -> dao.insert(new PersonEntity(1, "O'Brien")));
}
@Test
void whenGetAPersonById_thenItReturnThePersonInDatabase() throws SQLException {
dao.insert(new PersonEntity(1, "john"));
Optional<PersonEntity> maybeEmployee = dao.getById(1);
assertTrue(maybeEmployee.isPresent());
PersonEntity personEntity = maybeEmployee.get();
assertEquals(1, personEntity.getId());
assertEquals("john", personEntity.getName());
}
@Test
void whenInsertAndGetMultiplePersons_thenItNeverThrowsAnException() throws SQLException {
assertDoesNotThrow(() -> dao.insert(
Arrays.asList(new PersonEntity(1, "john"), new PersonEntity(2, "skit"))));
List<PersonEntity> result = dao.getAll();
assertEquals(Arrays.asList(new PersonEntity(1, "john"), new PersonEntity(2, "skit")),
result);
}
@Test
void whenUpdateAnExistentPerson_thenItReturnsTheUpdatedPerson() throws SQLException {
dao.insert(new PersonEntity(1, "john"));
dao.update(new PersonEntity(1, "johnny"));
Optional<PersonEntity> maybePerson = dao.getById(1);
assertTrue(maybePerson.isPresent());
PersonEntity personEntity = maybePerson.get();
assertEquals(1, personEntity.getId());
assertEquals("johnny", personEntity.getName());
}
@Test
void whenDeleteAPersonById_thenItWillBeAbsentInDatabase() throws SQLException {
dao.insert(new PersonEntity(1, "john"));
dao.deleteById(1);
Optional<PersonEntity> maybePerson = dao.getById(1);
assertFalse(maybePerson.isPresent());
}
@Test
void whenAHackerUpdateAPerson_thenItUpdatesTheTargetPerson() throws SQLException {
dao.insert(Arrays.asList(new PersonEntity(1, "john"), new PersonEntity(2, "skeet")));
dao.update(new PersonEntity(1, "hacker' --"));
List<PersonEntity> result = dao.getAll();
assertEquals(Arrays.asList(new PersonEntity(1, "hacker' --"), new PersonEntity(2, "skeet")),
result);
}
}
@@ -0,0 +1,96 @@
package com.baeldung.statmentVsPreparedstatment;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.*;
class StatementPersonDaoUnitTest {
private StatementPersonDao dao;
@BeforeEach
void setup() throws SQLException, ClassNotFoundException {
DatasourceFactory datasourceFactory = new DatasourceFactory();
Connection connection = datasourceFactory.getConnection();
datasourceFactory.createTables();
dao = new StatementPersonDao(connection);
}
@Test
void whenInsertAPerson_thenItNeverThrowsAnException() {
assertDoesNotThrow(() -> dao.insert(new PersonEntity(1, "john")));
}
@Test
void whenInsertAPersonWithQuoteInText_thenItWillThrowAnException() {
assertThrows(SQLException.class, () -> dao.insert(new PersonEntity(1, "O'Brien")));
}
@Test
void whenGetAPersonById_thenItReturnThePersonInDatabase() throws SQLException {
dao.insert(new PersonEntity(1, "john"));
Optional<PersonEntity> maybeEmployee = dao.getById(1);
assertTrue(maybeEmployee.isPresent());
PersonEntity personEntity = maybeEmployee.get();
assertEquals(1, personEntity.getId());
assertEquals("john", personEntity.getName());
}
@Test
void whenInsertAndGetMultiplePersons_thenItNeverThrowsAnException() throws SQLException {
assertDoesNotThrow(() -> dao.insert(
Arrays.asList(new PersonEntity(1, "john"), new PersonEntity(2, "skeet"))));
List<PersonEntity> result = dao.getAll();
assertEquals(Arrays.asList(new PersonEntity(1, "john"), new PersonEntity(2, "skeet")),
result);
}
@Test
void whenUpdateAnExistentPerson_thenItReturnsTheUpdatedPerson() throws SQLException {
dao.insert(new PersonEntity(1, "john"));
dao.update(new PersonEntity(1, "johnny"));
Optional<PersonEntity> maybePerson = dao.getById(1);
assertTrue(maybePerson.isPresent());
PersonEntity personEntity = maybePerson.get();
assertEquals(1, personEntity.getId());
assertEquals("johnny", personEntity.getName());
}
@Test
void whenDeleteAPersonById_thenItWillBeAbsentInDatabase() throws SQLException {
dao.insert(new PersonEntity(1, "john"));
dao.deleteById(1);
Optional<PersonEntity> maybePerson = dao.getById(1);
assertFalse(maybePerson.isPresent());
}
@Test
void whenAHackerUpdateAPerson_thenItAllPersonsAreUpdated() throws SQLException {
dao.insert(Arrays.asList(new PersonEntity(1, "john"), new PersonEntity(2, "skeet")));
dao.update(new PersonEntity(1, "hacker' --"));
List<PersonEntity> result = dao.getAll();
assertEquals(Arrays.asList(new PersonEntity(1, "hacker"), new PersonEntity(2, "hacker")),
result);
}
}
@@ -1,3 +1,5 @@
### Relevant Articles:
- [Hibernate could not initialize proxy – no Session](https://www.baeldung.com/hibernate-initialize-proxy-exception)
- [Hibernate Error “No Persistence Provider for EntityManager”](https://www.baeldung.com/hibernate-no-persistence-provider)
- [TransactionRequiredException Error](https://www.baeldung.com/jpa-transaction-required-exception)
@@ -11,7 +11,5 @@ This module contains articles specific to use of Hibernate as a JPA implementati
- [Criteria API – An Example of IN Expressions](https://www.baeldung.com/jpa-criteria-api-in-expressions)
- [One-to-One Relationship in JPA](https://www.baeldung.com/jpa-one-to-one)
- [Enabling Transaction Locks in Spring Data JPA](https://www.baeldung.com/java-jpa-transaction-locks)
- [TransactionRequiredException Error](https://www.baeldung.com/jpa-transaction-required-exception)
- [JPA/Hibernate Persistence Context](https://www.baeldung.com/jpa-hibernate-persistence-context)
- [Quick Guide to EntityManager#getReference()](https://www.baeldung.com/jpa-entity-manager-get-reference)
- [Hibernate Error “No Persistence Provider for EntityManager”](https://www.baeldung.com/hibernate-no-persistence-provider)
@@ -98,7 +98,6 @@
<cglib.version>3.2.4</cglib.version>
<nosqlunit.version>0.10.0</nosqlunit.version>
<embedded-redis.version>0.6</embedded-redis.version>
<spring-boot.version>2.1.9.RELEASE</spring-boot.version>
</properties>
</project>
@@ -31,11 +31,6 @@ public class RedisConfig {
return new ReactiveRedisTemplate<>(factory, context);
}
@Bean
public ReactiveRedisTemplate<String, String> reactiveRedisTemplateString(ReactiveRedisConnectionFactory connectionFactory) {
return new ReactiveRedisTemplate<>(connectionFactory, RedisSerializationContext.string());
}
@Bean
public ReactiveKeyCommands keyCommands(final ReactiveRedisConnectionFactory reactiveRedisConnectionFactory) {
return reactiveRedisConnectionFactory.getReactiveConnection()
@@ -0,0 +1,13 @@
package com.baeldung.spring.data.redis;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringRedisApplication {
public static void main(String[] args) {
SpringApplication.run(SpringRedisApplication.class, args);
}
}
@@ -2,9 +2,6 @@ package com.baeldung.spring.data.reactive.redis.template;
import com.baeldung.spring.data.reactive.redis.SpringRedisReactiveApplication;
import java.io.IOException;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -13,7 +10,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.ReactiveListOperations;
import org.springframework.data.redis.core.ReactiveRedisTemplate;
import org.springframework.data.redis.core.ReactiveStringRedisTemplate;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.junit4.SpringRunner;
@@ -21,6 +18,8 @@ import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import redis.embedded.RedisServerBuilder;
import java.io.IOException;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringRedisReactiveApplication.class)
@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
@@ -30,7 +29,7 @@ public class RedisTemplateListOpsIntegrationTest {
private static redis.embedded.RedisServer redisServer;
@Autowired
private ReactiveRedisTemplate<String, String> redisTemplate;
private ReactiveStringRedisTemplate redisTemplate;
private ReactiveListOperations<String, String> reactiveListOps;
@@ -1,44 +1,40 @@
package com.baeldung.spring.data.redis;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.UUID;
import com.baeldung.spring.data.redis.queue.RedisMessagePublisher;
import com.baeldung.spring.data.redis.queue.RedisMessageSubscriber;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.baeldung.spring.data.redis.config.RedisConfig;
import com.baeldung.spring.data.redis.queue.RedisMessagePublisher;
import com.baeldung.spring.data.redis.queue.RedisMessageSubscriber;
import org.springframework.test.context.junit4.SpringRunner;
import redis.embedded.RedisServerBuilder;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = RedisConfig.class)
import java.util.UUID;
import static org.junit.Assert.assertTrue;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringRedisApplication.class)
@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
public class RedisMessageListenerIntegrationTest {
private static redis.embedded.RedisServer redisServer;
@Autowired
private RedisMessagePublisher redisMessagePublisher;
@BeforeClass
public static void startRedisServer() throws IOException {
public static void startRedisServer() {
redisServer = new RedisServerBuilder().port(6379).setting("maxmemory 256M").build();
redisServer.start();
}
@AfterClass
public static void stopRedisServer() throws IOException {
public static void stopRedisServer() {
redisServer.stop();
}
+6
View File
@@ -386,6 +386,7 @@
<module>core-java-modules</module>
<module>core-kotlin-modules</module>
<module>core-scala</module>
<module>couchbase</module>
<module>custom-pmd</module>
@@ -559,6 +560,7 @@
<module>atomikos</module>
<module>reactive-systems</module>
<module>slack</module>
</modules>
</profile>
@@ -707,6 +709,7 @@
<module>spring-rest-shell</module>
<module>spring-rest-simple</module>
<module>spring-resttemplate</module>
<module>spring-resttemplate-2</module>
<module>spring-rest-testing</module>
<module>spring-roo</module>
@@ -901,6 +904,7 @@
<module>core-java-modules</module>
<module>core-kotlin-modules</module>
<module>core-scala</module>
<module>couchbase</module>
<module>custom-pmd</module>
@@ -1071,6 +1075,7 @@
<module>atomikos</module>
<module>reactive-systems</module>
<module>slack</module>
</modules>
</profile>
@@ -1211,6 +1216,7 @@
<module>spring-rest-shell</module>
<module>spring-rest-simple</module>
<module>spring-resttemplate</module>
<module>spring-resttemplate-2</module>
<module>spring-rest-testing</module>
<module>spring-roo</module>
@@ -116,7 +116,6 @@
<properties>
<guava.version>18.0</guava.version>
<junit-platform.version>1.2.0</junit-platform.version>
<git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
</properties>
@@ -41,7 +41,5 @@
<properties>
<java.version>1.8</java.version>
<spring-boot-starter-data-jpa.version>2.2.5.RELEASE</spring-boot-starter-data-jpa.version>
<junit.version>4.11</junit.version>
</properties>
</project>
+12 -14
View File
@@ -10,9 +10,9 @@
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
<artifactId>parent-boot-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2</relativePath>
</parent>
<modules>
@@ -56,17 +56,15 @@
</build>
<properties>
<spring-session.version>1.2.2.RELEASE</spring-session.version>
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
<spring-cloud-starter-config.version>1.2.2.RELEASE</spring-cloud-starter-config.version>
<spring-cloud-config-server.version>1.2.2.RELEASE</spring-cloud-config-server.version>
<spring-cloud-starter-eureka.version>2.0.2.RELEASE</spring-cloud-starter-eureka.version>
<spring-cloud-starter-feign.version>1.4.6.RELEASE</spring-cloud-starter-feign.version>
<spring-cloud-starter-hystrix.version>1.2.3.RELEASE</spring-cloud-starter-hystrix.version>
<spring-cloud-stream.version>1.3.0.RELEASE</spring-cloud-stream.version>
<spring-boot-starter-web.version>1.4.2.RELEASE</spring-boot-starter-web.version>
<spring-boot-maven-plugin.version>1.4.2.RELEASE</spring-boot-maven-plugin.version>
<spring-cloud-starter-zuul.version>1.2.3.RELEASE</spring-cloud-starter-zuul.version>
<spring-cloud-dependencies.version>Hoxton.SR4</spring-cloud-dependencies.version>
<spring-cloud-starter-config.version>2.2.3.RELEASE</spring-cloud-starter-config.version>
<spring-cloud-config-server.version>2.2.3.RELEASE</spring-cloud-config-server.version>
<spring-cloud-starter-eureka.version>1.4.7.RELEASE</spring-cloud-starter-eureka.version>
<spring-cloud-starter-feign.version>1.4.7.RELEASE</spring-cloud-starter-feign.version>
<spring-cloud-starter-hystrix.version>1.4.7.RELEASE</spring-cloud-starter-hystrix.version>
<spring-cloud-stream.version>3.0.6.RELEASE</spring-cloud-stream.version>
<spring-boot-starter-web.version>2.3.1.RELEASE</spring-boot-starter-web.version>
<spring-boot-maven-plugin.version>2.3.1.RELEASE</spring-boot-maven-plugin.version>
</properties>
</project>
@@ -4,12 +4,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import static org.springframework.boot.WebApplicationType.NONE;
@SpringBootApplication
@EnableDiscoveryClient
public class DiscoveryClientApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(DiscoveryClientApplication.class).web(true)
new SpringApplicationBuilder(DiscoveryClientApplication.class).web(NONE)
.run(args);
}
@@ -1,13 +1,16 @@
package com.baeldung.spring.cloud.consul.health;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import static org.springframework.boot.WebApplicationType.NONE;
@SpringBootApplication
public class ServiceDiscoveryApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(ServiceDiscoveryApplication.class).web(true)
new SpringApplicationBuilder(ServiceDiscoveryApplication.class).web(NONE)
.run(args);
}
@@ -4,12 +4,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.boot.WebApplicationType.NONE;
@SpringBootApplication
@RestController
public class DistributedPropertiesApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(DistributedPropertiesApplication.class).web(true)
new SpringApplicationBuilder(DistributedPropertiesApplication.class).web(NONE)
.run(args);
}
@@ -85,7 +85,6 @@
<spring-cloud-function.version>1.0.1.RELEASE</spring-cloud-function.version>
<aws-lambda-events.version>2.0.2</aws-lambda-events.version>
<aws-lambda-java-core.version>1.1.0</aws-lambda-java-core.version>
<spring-boot.version>2.0.4.RELEASE</spring-boot.version>
<spring-boot-thin.version>1.0.10.RELEASE</spring-boot-thin.version>
</properties>
@@ -36,18 +36,22 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>${spring-cloud-starter-hystrix.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
<version>${spring-cloud-starter-hystrix.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
<version>${spring-cloud-starter-feign.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot-starter-web.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -1,7 +1,7 @@
package com.baeldung.spring.cloud.hystrix.rest.consumer;
import com.baeldung.spring.cloud.hystrix.rest.producer.GreetingController;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
@@ -3,8 +3,8 @@ package com.baeldung.spring.cloud.hystrix.rest.consumer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableCircuitBreaker

Some files were not shown because too many files have changed in this diff Show More