Merge branch 'master' of https://github.com/eugenp/tutorials
This commit is contained in:
commit
ad4d301e93
@ -1,11 +1,18 @@
|
|||||||
package com.baeldung.concurrent.executorservice;
|
package com.baeldung.concurrent.executorservice;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
public class DelayedCallable implements Callable<String> {
|
public class DelayedCallable implements Callable<String> {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private long period;
|
private long period;
|
||||||
|
private CountDownLatch latch;
|
||||||
|
|
||||||
|
public DelayedCallable(String name, long period, CountDownLatch latch) {
|
||||||
|
this(name, period);
|
||||||
|
this.latch = latch;
|
||||||
|
}
|
||||||
|
|
||||||
public DelayedCallable(String name, long period) {
|
public DelayedCallable(String name, long period) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -16,9 +23,15 @@ public class DelayedCallable implements Callable<String> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(period);
|
Thread.sleep(period);
|
||||||
|
|
||||||
|
if (latch != null) {
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
// handle exception
|
// handle exception
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
@ -9,22 +9,91 @@ import java.util.List;
|
|||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertTrue;
|
import static junit.framework.TestCase.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class WaitingForThreadsToFinishTest {
|
public class WaitingForThreadsToFinishTest {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(WaitingForThreadsToFinishTest.class);
|
private static final Logger LOG = LoggerFactory.getLogger(WaitingForThreadsToFinishTest.class);
|
||||||
private final static ExecutorService WORKER_THREAD_POOL = Executors.newFixedThreadPool(10);
|
private final static ExecutorService WORKER_THREAD_POOL = Executors.newFixedThreadPool(10);
|
||||||
|
|
||||||
|
public void awaitTerminationAfterShutdown(ExecutorService threadPool) {
|
||||||
|
threadPool.shutdown();
|
||||||
|
try {
|
||||||
|
if (!threadPool.awaitTermination(60, TimeUnit.SECONDS)) {
|
||||||
|
threadPool.shutdownNow();
|
||||||
|
}
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
threadPool.shutdownNow();
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenMultipleThreads_whenUsingCountDownLatch_thenMainShoudWaitForAllToFinish() {
|
||||||
|
|
||||||
|
ExecutorService WORKER_THREAD_POOL = Executors.newFixedThreadPool(10);
|
||||||
|
|
||||||
|
try {
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
// create a CountDownLatch that waits for the 2 threads to finish
|
||||||
|
CountDownLatch latch = new CountDownLatch(2);
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
WORKER_THREAD_POOL.submit(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
latch.countDown();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait for the latch to be decremented by the two threads
|
||||||
|
latch.await();
|
||||||
|
|
||||||
|
long processingTime = System.currentTimeMillis() - startTime;
|
||||||
|
assertTrue(processingTime >= 1000);
|
||||||
|
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
awaitTerminationAfterShutdown(WORKER_THREAD_POOL);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenMultipleThreads_whenInvokeAll_thenMainThreadShouldWaitForAllToFinish() {
|
public void givenMultipleThreads_whenInvokeAll_thenMainThreadShouldWaitForAllToFinish() {
|
||||||
|
|
||||||
ExecutorService WORKER_THREAD_POOL = Executors.newFixedThreadPool(10);
|
ExecutorService WORKER_THREAD_POOL = Executors.newFixedThreadPool(10);
|
||||||
|
|
||||||
List<Callable<String>> callables = Arrays.asList(new DelayedCallable("fast thread", 100), new DelayedCallable("slow thread", 3000));
|
List<Callable<String>> callables = Arrays.asList(
|
||||||
|
new DelayedCallable("fast thread", 100),
|
||||||
|
new DelayedCallable("slow thread", 3000));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
long startProcessingTime = System.currentTimeMillis();
|
long startProcessingTime = System.currentTimeMillis();
|
||||||
List<Future<String>> futures = WORKER_THREAD_POOL.invokeAll(callables);
|
List<Future<String>> futures = WORKER_THREAD_POOL.invokeAll(callables);
|
||||||
|
|
||||||
|
awaitTerminationAfterShutdown(WORKER_THREAD_POOL);
|
||||||
|
|
||||||
|
try {
|
||||||
|
WORKER_THREAD_POOL.submit(new Callable<String>() {
|
||||||
|
@Override
|
||||||
|
public String call() throws Exception {
|
||||||
|
fail("This thread should have been rejected !");
|
||||||
|
Thread.sleep(1000000);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (RejectedExecutionException ex) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
long totalProcessingTime = System.currentTimeMillis() - startProcessingTime;
|
long totalProcessingTime = System.currentTimeMillis() - startProcessingTime;
|
||||||
assertTrue(totalProcessingTime >= 3000);
|
assertTrue(totalProcessingTime >= 3000);
|
||||||
@ -39,9 +108,7 @@ public class WaitingForThreadsToFinishTest {
|
|||||||
|
|
||||||
} catch (ExecutionException | InterruptedException ex) {
|
} catch (ExecutionException | InterruptedException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
WORKER_THREAD_POOL.shutdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -49,14 +116,14 @@ public class WaitingForThreadsToFinishTest {
|
|||||||
|
|
||||||
CompletionService<String> service = new ExecutorCompletionService<>(WORKER_THREAD_POOL);
|
CompletionService<String> service = new ExecutorCompletionService<>(WORKER_THREAD_POOL);
|
||||||
|
|
||||||
List<Callable<String>> callables = Arrays.asList(new DelayedCallable("fast thread", 100), new DelayedCallable("slow thread", 3000));
|
List<Callable<String>> callables = Arrays.asList(
|
||||||
|
new DelayedCallable("fast thread", 100),
|
||||||
|
new DelayedCallable("slow thread", 3000));
|
||||||
|
|
||||||
for (Callable<String> callable : callables) {
|
for (Callable<String> callable : callables) {
|
||||||
service.submit(callable);
|
service.submit(callable);
|
||||||
}
|
}
|
||||||
|
|
||||||
WORKER_THREAD_POOL.shutdown();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
long startProcessingTime = System.currentTimeMillis();
|
long startProcessingTime = System.currentTimeMillis();
|
||||||
@ -79,8 +146,9 @@ public class WaitingForThreadsToFinishTest {
|
|||||||
|
|
||||||
} catch (ExecutionException | InterruptedException ex) {
|
} catch (ExecutionException | InterruptedException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
awaitTerminationAfterShutdown(WORKER_THREAD_POOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -142,6 +210,6 @@ public class WaitingForThreadsToFinishTest {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
WORKER_THREAD_POOL.shutdown();
|
awaitTerminationAfterShutdown(WORKER_THREAD_POOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@
|
|||||||
<exclude>**/*LongRunningUnitTest.java</exclude>
|
<exclude>**/*LongRunningUnitTest.java</exclude>
|
||||||
<exclude>**/*ManualTest.java</exclude>
|
<exclude>**/*ManualTest.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@ -15,5 +15,6 @@
|
|||||||
- [Data Classes in Kotlin](http://www.baeldung.com/kotlin-data-classes)
|
- [Data Classes in Kotlin](http://www.baeldung.com/kotlin-data-classes)
|
||||||
- [Delegated Properties in Kotlin](http://www.baeldung.com/kotlin-delegated-properties)
|
- [Delegated Properties in Kotlin](http://www.baeldung.com/kotlin-delegated-properties)
|
||||||
- [Sealed Classes in Kotlin](http://www.baeldung.com/kotlin-sealed-classes)
|
- [Sealed Classes in Kotlin](http://www.baeldung.com/kotlin-sealed-classes)
|
||||||
|
- [JUnit 5 for Kotlin Developers](http://www.baeldung.com/junit-5-kotlin)
|
||||||
|
|
||||||
|
|
||||||
|
17
guest/spring-mvc/README.md
Normal file
17
guest/spring-mvc/README.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
## Building
|
||||||
|
|
||||||
|
To build the module, use Maven's `package` goal:
|
||||||
|
|
||||||
|
```
|
||||||
|
mvn clean package
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running
|
||||||
|
|
||||||
|
To run the application, use Spring Boot's `run` goal:
|
||||||
|
|
||||||
|
```
|
||||||
|
mvn spring-boot:run
|
||||||
|
```
|
||||||
|
|
||||||
|
The application will be accessible at [http://localhost:8080/](http://localhost:8080/)
|
@ -3,6 +3,7 @@ package com.baeldung.hibernate;
|
|||||||
import com.baeldung.hibernate.pojo.Employee;
|
import com.baeldung.hibernate.pojo.Employee;
|
||||||
import com.baeldung.hibernate.pojo.EntityDescription;
|
import com.baeldung.hibernate.pojo.EntityDescription;
|
||||||
import com.baeldung.hibernate.pojo.Phone;
|
import com.baeldung.hibernate.pojo.Phone;
|
||||||
|
import com.baeldung.hibernate.pojo.TemporalValues;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.boot.Metadata;
|
import org.hibernate.boot.Metadata;
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
@ -31,6 +32,7 @@ public class HibernateUtil {
|
|||||||
metadataSources.addAnnotatedClass(Employee.class);
|
metadataSources.addAnnotatedClass(Employee.class);
|
||||||
metadataSources.addAnnotatedClass(Phone.class);
|
metadataSources.addAnnotatedClass(Phone.class);
|
||||||
metadataSources.addAnnotatedClass(EntityDescription.class);
|
metadataSources.addAnnotatedClass(EntityDescription.class);
|
||||||
|
metadataSources.addAnnotatedClass(TemporalValues.class);
|
||||||
|
|
||||||
Metadata metadata = metadataSources.buildMetadata();
|
Metadata metadata = metadataSources.buildMetadata();
|
||||||
return metadata.getSessionFactoryBuilder()
|
return metadata.getSessionFactoryBuilder()
|
||||||
|
@ -0,0 +1,195 @@
|
|||||||
|
package com.baeldung.hibernate.pojo;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.sql.Time;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.time.*;
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class TemporalValues implements Serializable {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
private java.sql.Date sqlDate;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
private java.sql.Time sqlTime;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
private java.sql.Timestamp sqlTimestamp;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
@Temporal(TemporalType.DATE)
|
||||||
|
private java.util.Date utilDate;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
@Temporal(TemporalType.TIME)
|
||||||
|
private java.util.Date utilTime;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private java.util.Date utilTimestamp;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
@Temporal(TemporalType.DATE)
|
||||||
|
private java.util.Calendar calendarDate;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private java.util.Calendar calendarTimestamp;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
private java.time.LocalDate localDate;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
private java.time.LocalTime localTime;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
private java.time.OffsetTime offsetTime;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
private java.time.Instant instant;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
private java.time.LocalDateTime localDateTime;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
private java.time.OffsetDateTime offsetDateTime;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
private java.time.ZonedDateTime zonedDateTime;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getSqlDate() {
|
||||||
|
return sqlDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSqlDate(Date sqlDate) {
|
||||||
|
this.sqlDate = sqlDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Time getSqlTime() {
|
||||||
|
return sqlTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSqlTime(Time sqlTime) {
|
||||||
|
this.sqlTime = sqlTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getSqlTimestamp() {
|
||||||
|
return sqlTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSqlTimestamp(Timestamp sqlTimestamp) {
|
||||||
|
this.sqlTimestamp = sqlTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.util.Date getUtilDate() {
|
||||||
|
return utilDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUtilDate(java.util.Date utilDate) {
|
||||||
|
this.utilDate = utilDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.util.Date getUtilTime() {
|
||||||
|
return utilTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUtilTime(java.util.Date utilTime) {
|
||||||
|
this.utilTime = utilTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.util.Date getUtilTimestamp() {
|
||||||
|
return utilTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUtilTimestamp(java.util.Date utilTimestamp) {
|
||||||
|
this.utilTimestamp = utilTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Calendar getCalendarDate() {
|
||||||
|
return calendarDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCalendarDate(Calendar calendarDate) {
|
||||||
|
this.calendarDate = calendarDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Calendar getCalendarTimestamp() {
|
||||||
|
return calendarTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCalendarTimestamp(Calendar calendarTimestamp) {
|
||||||
|
this.calendarTimestamp = calendarTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getLocalDate() {
|
||||||
|
return localDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocalDate(LocalDate localDate) {
|
||||||
|
this.localDate = localDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalTime getLocalTime() {
|
||||||
|
return localTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocalTime(LocalTime localTime) {
|
||||||
|
this.localTime = localTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OffsetTime getOffsetTime() {
|
||||||
|
return offsetTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOffsetTime(OffsetTime offsetTime) {
|
||||||
|
this.offsetTime = offsetTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getInstant() {
|
||||||
|
return instant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstant(Instant instant) {
|
||||||
|
this.instant = instant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getLocalDateTime() {
|
||||||
|
return localDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocalDateTime(LocalDateTime localDateTime) {
|
||||||
|
this.localDateTime = localDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OffsetDateTime getOffsetDateTime() {
|
||||||
|
return offsetDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOffsetDateTime(OffsetDateTime offsetDateTime) {
|
||||||
|
this.offsetDateTime = offsetDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZonedDateTime getZonedDateTime() {
|
||||||
|
return zonedDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZonedDateTime(ZonedDateTime zonedDateTime) {
|
||||||
|
this.zonedDateTime = zonedDateTime;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,126 @@
|
|||||||
|
package com.baeldung.hibernate;
|
||||||
|
|
||||||
|
import com.baeldung.hibernate.pojo.TemporalValues;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.Transaction;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.*;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
public class TemporalValuesTest {
|
||||||
|
|
||||||
|
private Session session;
|
||||||
|
|
||||||
|
private Transaction transaction;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws IOException {
|
||||||
|
session = HibernateUtil.getSessionFactory().withOptions()
|
||||||
|
.jdbcTimeZone(TimeZone.getTimeZone("UTC"))
|
||||||
|
.openSession();
|
||||||
|
transaction = session.beginTransaction();
|
||||||
|
session.createNativeQuery("delete from temporalvalues").executeUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
transaction.rollback();
|
||||||
|
session.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenEntity_whenMappingSqlTypes_thenTemporalIsSelectedAutomatically() {
|
||||||
|
TemporalValues temporalValues = new TemporalValues();
|
||||||
|
temporalValues.setSqlDate(java.sql.Date.valueOf("2017-11-15"));
|
||||||
|
temporalValues.setSqlTime(java.sql.Time.valueOf("15:30:14"));
|
||||||
|
temporalValues.setSqlTimestamp(java.sql.Timestamp.valueOf("2017-11-15 15:30:14.332"));
|
||||||
|
|
||||||
|
session.save(temporalValues);
|
||||||
|
session.flush();
|
||||||
|
session.clear();
|
||||||
|
|
||||||
|
temporalValues = session.get(TemporalValues.class, temporalValues.getId());
|
||||||
|
assertThat(temporalValues.getSqlDate()).isEqualTo(java.sql.Date.valueOf("2017-11-15"));
|
||||||
|
assertThat(temporalValues.getSqlTime()).isEqualTo(java.sql.Time.valueOf("15:30:14"));
|
||||||
|
assertThat(temporalValues.getSqlTimestamp()).isEqualTo(java.sql.Timestamp.valueOf("2017-11-15 15:30:14.332"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenEntity_whenMappingUtilDateType_thenTemporalIsSpecifiedExplicitly() throws Exception {
|
||||||
|
TemporalValues temporalValues = new TemporalValues();
|
||||||
|
temporalValues.setUtilDate(new SimpleDateFormat("yyyy-MM-dd").parse("2017-11-15"));
|
||||||
|
temporalValues.setUtilTime(new SimpleDateFormat("HH:mm:ss").parse("15:30:14"));
|
||||||
|
temporalValues.setUtilTimestamp(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse("2017-11-15 15:30:14.332"));
|
||||||
|
|
||||||
|
session.save(temporalValues);
|
||||||
|
session.flush();
|
||||||
|
session.clear();
|
||||||
|
|
||||||
|
temporalValues = session.get(TemporalValues.class, temporalValues.getId());
|
||||||
|
assertThat(temporalValues.getUtilDate()).isEqualTo(new SimpleDateFormat("yyyy-MM-dd").parse("2017-11-15"));
|
||||||
|
assertThat(temporalValues.getUtilTime()).isEqualTo(new SimpleDateFormat("HH:mm:ss").parse("15:30:14"));
|
||||||
|
assertThat(temporalValues.getUtilTimestamp()).isEqualTo(java.sql.Timestamp.valueOf("2017-11-15 15:30:14.332"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenEntity_whenMappingCalendarType_thenTemporalIsSpecifiedExplicitly() throws Exception {
|
||||||
|
TemporalValues temporalValues = new TemporalValues();
|
||||||
|
|
||||||
|
Calendar calendarDate = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
||||||
|
calendarDate.set(Calendar.YEAR, 2017);
|
||||||
|
calendarDate.set(Calendar.MONTH, 10);
|
||||||
|
calendarDate.set(Calendar.DAY_OF_MONTH, 15);
|
||||||
|
temporalValues.setCalendarDate(calendarDate);
|
||||||
|
|
||||||
|
Calendar calendarTimestamp = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
||||||
|
calendarTimestamp.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse("2017-11-15 15:30:14.322"));
|
||||||
|
temporalValues.setCalendarTimestamp(calendarTimestamp);
|
||||||
|
|
||||||
|
session.save(temporalValues);
|
||||||
|
session.flush();
|
||||||
|
session.clear();
|
||||||
|
|
||||||
|
temporalValues = session.get(TemporalValues.class, temporalValues.getId());
|
||||||
|
assertThat(temporalValues.getCalendarDate().getTime()).isEqualTo(new SimpleDateFormat("yyyy-MM-dd").parse("2017-11-15"));
|
||||||
|
assertThat(temporalValues.getCalendarTimestamp().getTime()).isEqualTo(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse("2017-11-15 15:30:14.322"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenEntity_whenMappingJavaTimeTypes_thenTemporalIsSelectedAutomatically() {
|
||||||
|
TemporalValues temporalValues = new TemporalValues();
|
||||||
|
|
||||||
|
temporalValues.setLocalDate(LocalDate.parse("2017-11-15"));
|
||||||
|
temporalValues.setLocalTime(LocalTime.parse("15:30:18"));
|
||||||
|
temporalValues.setOffsetTime(OffsetTime.parse("08:22:12+01:00"));
|
||||||
|
temporalValues.setInstant(Instant.parse("2017-11-15T08:22:12Z"));
|
||||||
|
temporalValues.setLocalDateTime(LocalDateTime.parse("2017-11-15T08:22:12"));
|
||||||
|
temporalValues.setOffsetDateTime(OffsetDateTime.parse("2017-11-15T08:22:12+01:00"));
|
||||||
|
temporalValues.setZonedDateTime(ZonedDateTime.parse("2017-11-15T08:22:12+01:00[Europe/Paris]"));
|
||||||
|
|
||||||
|
session.save(temporalValues);
|
||||||
|
session.flush();
|
||||||
|
session.clear();
|
||||||
|
|
||||||
|
temporalValues = session.get(TemporalValues.class, temporalValues.getId());
|
||||||
|
assertThat(temporalValues.getLocalDate()).isEqualTo(LocalDate.parse("2017-11-15"));
|
||||||
|
assertThat(temporalValues.getLocalTime()).isEqualTo(LocalTime.parse("15:30:18"));
|
||||||
|
assertThat(temporalValues.getOffsetTime()).isEqualTo(OffsetTime.parse("08:22:12+01:00"));
|
||||||
|
assertThat(temporalValues.getInstant()).isEqualTo(Instant.parse("2017-11-15T08:22:12Z"));
|
||||||
|
assertThat(temporalValues.getLocalDateTime()).isEqualTo(LocalDateTime.parse("2017-11-15T08:22:12"));
|
||||||
|
assertThat(temporalValues.getOffsetDateTime()).isEqualTo(OffsetDateTime.parse("2017-11-15T08:22:12+01:00"));
|
||||||
|
assertThat(temporalValues.getZonedDateTime()).isEqualTo(ZonedDateTime.parse("2017-11-15T08:22:12+01:00[Europe/Paris]"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -29,6 +29,7 @@
|
|||||||
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
||||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||||
<junit4.version>4.12</junit4.version>
|
<junit4.version>4.12</junit4.version>
|
||||||
|
<spring.version>5.0.1.RELEASE</spring.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -111,6 +112,17 @@
|
|||||||
<version>${junit4.version}</version>
|
<version>${junit4.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
<version>${spring.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-context</artifactId>
|
||||||
|
<version>${spring.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.baeldung.junit5.spring;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
|
||||||
|
import com.baeldung.junit5.Greetings;
|
||||||
|
|
||||||
|
@ExtendWith(SpringExtension.class)
|
||||||
|
@ContextConfiguration(classes = { SpringTestConfiguration.class })
|
||||||
|
public class GreetingsSpringTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenCallingSayHello_thenReturnHello() {
|
||||||
|
assertTrue("Hello".equals(Greetings.sayHello()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.baeldung.junit5.spring;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SpringTestConfiguration {
|
||||||
|
|
||||||
|
}
|
@ -51,7 +51,6 @@ public class MemberStatusIntegrationTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This test should fail, comment out <code>@Ignore</code> to see how failed test can be reflected in Serenity report. <br/>
|
* This test should fail, comment out <code>@Ignore</code> to see how failed test can be reflected in Serenity report. <br/>
|
||||||
* Remember to add <code><testFailureIgnore>true</testFailureIgnore></code> under maven-surefire-plugin configuration.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
|
@ -26,12 +26,6 @@
|
|||||||
<version>${log4j.version}</version>
|
<version>${log4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
<artifactId>apache-log4j-extras</artifactId>
|
|
||||||
<version>${log4j.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--log4j2 dependencies -->
|
<!--log4j2 dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
@ -85,7 +85,6 @@
|
|||||||
<exclude>**/JdbcTest.java</exclude>
|
<exclude>**/JdbcTest.java</exclude>
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
<exclude>**/JdbcTest.java</exclude>
|
<exclude>**/JdbcTest.java</exclude>
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -65,7 +65,6 @@
|
|||||||
<exclude>**/*EntryPointsTest.java</exclude>
|
<exclude>**/*EntryPointsTest.java</exclude>
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
3
pom.xml
3
pom.xml
@ -256,6 +256,7 @@
|
|||||||
<module>vertx-and-rxjava</module>
|
<module>vertx-and-rxjava</module>
|
||||||
<module>saas</module>
|
<module>saas</module>
|
||||||
<module>deeplearning4j</module>
|
<module>deeplearning4j</module>
|
||||||
|
<module>spring-boot-admin</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -338,7 +339,7 @@
|
|||||||
<exclude>**/JdbcTest.java</exclude>
|
<exclude>**/JdbcTest.java</exclude>
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
<includes>
|
<includes>
|
||||||
<include>**/*LiveTest.java</include>
|
<include>**/*LiveTest.java</include>
|
||||||
</includes>
|
</includes>
|
||||||
<testFailureIgnore>false</testFailureIgnore>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
@ -152,7 +152,7 @@
|
|||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
|
||||||
<failIfNoTests>false</failIfNoTests>
|
<failIfNoTests>false</failIfNoTests>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/*IntegrationTest.java</exclude>
|
<exclude>**/*IntegrationTest.java</exclude>
|
||||||
|
@ -19,9 +19,11 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<start-class>com.example.activitiwithspring.ActivitiWithSpringApplication</start-class>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
<activiti.version>6.0.0</activiti.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -30,9 +32,14 @@
|
|||||||
<artifactId>activiti-spring-boot-starter-basic</artifactId>
|
<artifactId>activiti-spring-boot-starter-basic</artifactId>
|
||||||
<version>6.0.0</version>
|
<version>6.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.activiti</groupId>
|
||||||
|
<artifactId>activiti-spring-boot-starter-security</artifactId>
|
||||||
|
<version>${activiti.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -67,7 +74,7 @@
|
|||||||
<exclude>**/JdbcTest.java</exclude>
|
<exclude>**/JdbcTest.java</exclude>
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
BIN
spring-activiti/src/main/java/com/baeldung/activiti/security.rar
Normal file
BIN
spring-activiti/src/main/java/com/baeldung/activiti/security.rar
Normal file
Binary file not shown.
@ -0,0 +1,20 @@
|
|||||||
|
package com.baeldung.activiti.security.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableWebMvc
|
||||||
|
public class MvcConfig extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
|
registry.addViewController("/login")
|
||||||
|
.setViewName("login");
|
||||||
|
registry.addViewController("/homepage")
|
||||||
|
.setViewName("homepage");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.baeldung.activiti.security.config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.activiti.engine.IdentityService;
|
||||||
|
import org.activiti.engine.RuntimeService;
|
||||||
|
import org.activiti.engine.TaskService;
|
||||||
|
import org.activiti.engine.runtime.ProcessInstance;
|
||||||
|
import org.activiti.engine.task.Task;
|
||||||
|
import org.activiti.spring.SpringProcessEngineConfiguration;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class ProcessController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RuntimeService runtimeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TaskService taskService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IdentityService identityService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SpringProcessEngineConfiguration config;
|
||||||
|
|
||||||
|
@GetMapping("/protected-process")
|
||||||
|
public String startProcess() {
|
||||||
|
|
||||||
|
String userId = SecurityContextHolder.getContext()
|
||||||
|
.getAuthentication()
|
||||||
|
.getName();
|
||||||
|
|
||||||
|
identityService.setAuthenticatedUserId(userId);
|
||||||
|
|
||||||
|
ProcessInstance pi = runtimeService.startProcessInstanceByKey("protected-process");
|
||||||
|
|
||||||
|
List<Task> usertasks = taskService.createTaskQuery()
|
||||||
|
.processInstanceId(pi.getId())
|
||||||
|
.list();
|
||||||
|
|
||||||
|
taskService.complete(usertasks.iterator()
|
||||||
|
.next()
|
||||||
|
.getId());
|
||||||
|
|
||||||
|
return "Process started. Number of currently running process instances = " + runtimeService.createProcessInstanceQuery()
|
||||||
|
.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
package com.baeldung.activiti.security.config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.activiti.engine.identity.Group;
|
||||||
|
import org.activiti.engine.identity.GroupQuery;
|
||||||
|
import org.activiti.engine.impl.GroupQueryImpl;
|
||||||
|
import org.activiti.engine.impl.Page;
|
||||||
|
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||||
|
import org.activiti.engine.impl.persistence.entity.GroupEntityImpl;
|
||||||
|
import org.activiti.engine.impl.persistence.entity.GroupEntityManagerImpl;
|
||||||
|
import org.activiti.engine.impl.persistence.entity.data.GroupDataManager;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
import org.springframework.security.provisioning.JdbcUserDetailsManager;
|
||||||
|
|
||||||
|
public class SpringSecurityGroupManager extends GroupEntityManagerImpl {
|
||||||
|
|
||||||
|
private JdbcUserDetailsManager userManager;
|
||||||
|
|
||||||
|
public SpringSecurityGroupManager(ProcessEngineConfigurationImpl processEngineConfiguration, GroupDataManager groupDataManager) {
|
||||||
|
super(processEngineConfiguration, groupDataManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Group> findGroupByQueryCriteria(GroupQueryImpl query, Page page) {
|
||||||
|
|
||||||
|
if (query.getUserId() != null) {
|
||||||
|
return findGroupsByUser(query.getUserId());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long findGroupCountByQueryCriteria(GroupQueryImpl query) {
|
||||||
|
return findGroupByQueryCriteria(query, null).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Group> findGroupsByUser(String userId) {
|
||||||
|
UserDetails userDetails = userManager.loadUserByUsername(userId);
|
||||||
|
System.out.println("group manager");
|
||||||
|
if (userDetails != null) {
|
||||||
|
List<Group> groups = userDetails.getAuthorities()
|
||||||
|
.stream()
|
||||||
|
.map(a -> a.getAuthority())
|
||||||
|
.map(a -> {
|
||||||
|
Group g = new GroupEntityImpl();
|
||||||
|
g.setId(a);
|
||||||
|
return g;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserManager(JdbcUserDetailsManager userManager) {
|
||||||
|
this.userManager = userManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Group createNewGroup(String groupId) {
|
||||||
|
throw new UnsupportedOperationException("This operation is not supported!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(String groupId) {
|
||||||
|
throw new UnsupportedOperationException("This operation is not supported!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupQuery createNewGroupQuery() {
|
||||||
|
throw new UnsupportedOperationException("This operation is not supported!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Group> findGroupsByNativeQuery(Map<String, Object> parameterMap, int firstResult, int maxResults) {
|
||||||
|
throw new UnsupportedOperationException("This operation is not supported!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public long findGroupCountByNativeQuery(Map<String, Object> parameterMap) {
|
||||||
|
throw new UnsupportedOperationException("This operation is not supported!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,144 @@
|
|||||||
|
package com.baeldung.activiti.security.config;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.activiti.engine.identity.Group;
|
||||||
|
import org.activiti.engine.identity.User;
|
||||||
|
import org.activiti.engine.identity.UserQuery;
|
||||||
|
import org.activiti.engine.impl.Page;
|
||||||
|
import org.activiti.engine.impl.UserQueryImpl;
|
||||||
|
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||||
|
import org.activiti.engine.impl.persistence.entity.GroupEntityImpl;
|
||||||
|
import org.activiti.engine.impl.persistence.entity.UserEntity;
|
||||||
|
import org.activiti.engine.impl.persistence.entity.UserEntityImpl;
|
||||||
|
import org.activiti.engine.impl.persistence.entity.UserEntityManagerImpl;
|
||||||
|
import org.activiti.engine.impl.persistence.entity.data.UserDataManager;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
import org.springframework.security.provisioning.JdbcUserDetailsManager;
|
||||||
|
|
||||||
|
public class SpringSecurityUserManager extends UserEntityManagerImpl {
|
||||||
|
|
||||||
|
private JdbcUserDetailsManager userManager;
|
||||||
|
|
||||||
|
public SpringSecurityUserManager(ProcessEngineConfigurationImpl processEngineConfiguration, UserDataManager userDataManager, JdbcUserDetailsManager userManager) {
|
||||||
|
super(processEngineConfiguration, userDataManager);
|
||||||
|
this.userManager = userManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserEntity findById(String userId) {
|
||||||
|
UserDetails userDetails = userManager.loadUserByUsername(userId);
|
||||||
|
if (userDetails != null) {
|
||||||
|
UserEntityImpl user = new UserEntityImpl();
|
||||||
|
user.setId(userId);
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<User> findUserByQueryCriteria(UserQueryImpl query, Page page) {
|
||||||
|
List<User> users = null;
|
||||||
|
if (query.getGroupId() != null) {
|
||||||
|
users = userManager.findUsersInGroup(query.getGroupId())
|
||||||
|
.stream()
|
||||||
|
.map(username -> {
|
||||||
|
User user = new UserEntityImpl();
|
||||||
|
user.setId(username);
|
||||||
|
return user;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (page != null) {
|
||||||
|
return users.subList(page.getFirstResult(), page.getFirstResult() + page.getMaxResults());
|
||||||
|
|
||||||
|
}
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.getId() != null) {
|
||||||
|
UserDetails userDetails = userManager.loadUserByUsername(query.getId());
|
||||||
|
if (userDetails != null) {
|
||||||
|
UserEntityImpl user = new UserEntityImpl();
|
||||||
|
user.setId(query.getId());
|
||||||
|
return Collections.singletonList(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean checkPassword(String userId, String password) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserManager(JdbcUserDetailsManager userManager) {
|
||||||
|
this.userManager = userManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User createNewUser(String userId) {
|
||||||
|
throw new UnsupportedOperationException("This operation is not supported!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateUser(User updatedUser) {
|
||||||
|
throw new UnsupportedOperationException("This operation is not supported!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(UserEntity userEntity) {
|
||||||
|
throw new UnsupportedOperationException("This operation is not supported!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deletePicture(User user) {
|
||||||
|
UserEntity userEntity = (UserEntity) user;
|
||||||
|
if (userEntity.getPictureByteArrayRef() != null) {
|
||||||
|
userEntity.getPictureByteArrayRef()
|
||||||
|
.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(String userId) {
|
||||||
|
throw new UnsupportedOperationException("This operation is not supported!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public long findUserCountByQueryCriteria(UserQueryImpl query) {
|
||||||
|
return findUserByQueryCriteria(query, null).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Group> findGroupsByUser(String userId) {
|
||||||
|
UserDetails userDetails = userManager.loadUserByUsername(userId);
|
||||||
|
if (userDetails != null) {
|
||||||
|
List<Group> groups = userDetails.getAuthorities()
|
||||||
|
.stream()
|
||||||
|
.map(a -> a.getAuthority())
|
||||||
|
.map(a -> {
|
||||||
|
Group g = new GroupEntityImpl();
|
||||||
|
g.setId(a);
|
||||||
|
return g;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserQuery createNewUserQuery() {
|
||||||
|
throw new UnsupportedOperationException("This operation is not supported!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<User> findUsersByNativeQuery(Map<String, Object> parameterMap, int firstResult, int maxResults) {
|
||||||
|
throw new UnsupportedOperationException("This operation is not supported!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public long findUserCountByNativeQuery(Map<String, Object> parameterMap) {
|
||||||
|
throw new UnsupportedOperationException("This operation is not supported!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package com.baeldung.activiti.security.withactiviti;
|
||||||
|
|
||||||
|
import org.activiti.engine.IdentityService;
|
||||||
|
import org.activiti.spring.security.IdentityServiceUserDetailsService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
http.antMatcher("/**")
|
||||||
|
.authorizeRequests()
|
||||||
|
.antMatchers("/protected-process*")
|
||||||
|
.authenticated()
|
||||||
|
.anyRequest()
|
||||||
|
.permitAll()
|
||||||
|
.and()
|
||||||
|
.formLogin()
|
||||||
|
.loginPage("/login")
|
||||||
|
.defaultSuccessUrl("/homepage")
|
||||||
|
.failureUrl("/login?error=true")
|
||||||
|
.and()
|
||||||
|
.csrf()
|
||||||
|
.disable()
|
||||||
|
.logout()
|
||||||
|
.logoutSuccessUrl("/login");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IdentityService identityService;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public IdentityServiceUserDetailsService userDetailsService() {
|
||||||
|
return new IdentityServiceUserDetailsService(identityService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||||
|
auth.userDetailsService(userDetailsService());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.baeldung.activiti.security.withactiviti;
|
||||||
|
|
||||||
|
import org.activiti.engine.IdentityService;
|
||||||
|
import org.activiti.engine.identity.Group;
|
||||||
|
import org.activiti.engine.identity.User;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
|
@SpringBootApplication(scanBasePackages = { "com.baeldung.activiti.security.config", "com.baeldung.activiti.security.withactiviti" })
|
||||||
|
public class SpringSecurityActivitiApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(SpringSecurityActivitiApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
InitializingBean usersAndGroupsInitializer(IdentityService identityService) {
|
||||||
|
return new InitializingBean() {
|
||||||
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
User user = identityService.newUser("activiti_user");
|
||||||
|
user.setPassword("pass");
|
||||||
|
identityService.saveUser(user);
|
||||||
|
|
||||||
|
Group group = identityService.newGroup("user");
|
||||||
|
group.setName("ROLE_USER");
|
||||||
|
group.setType("USER");
|
||||||
|
identityService.saveGroup(group);
|
||||||
|
identityService.createMembership(user.getId(), group.getId());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.baeldung.activiti.security.withspring;
|
||||||
|
|
||||||
|
import org.activiti.engine.impl.persistence.entity.data.impl.MybatisGroupDataManager;
|
||||||
|
import org.activiti.engine.impl.persistence.entity.data.impl.MybatisUserDataManager;
|
||||||
|
import org.activiti.spring.SpringProcessEngineConfiguration;
|
||||||
|
import org.activiti.spring.boot.SecurityAutoConfiguration;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.security.provisioning.JdbcUserDetailsManager;
|
||||||
|
|
||||||
|
import com.baeldung.activiti.security.config.SpringSecurityGroupManager;
|
||||||
|
import com.baeldung.activiti.security.config.SpringSecurityUserManager;
|
||||||
|
|
||||||
|
@SpringBootApplication(exclude = SecurityAutoConfiguration.class, scanBasePackages = { "com.baeldung.activiti.security.config", "com.baeldung.activiti.security.withspring" })
|
||||||
|
public class ActivitiSpringSecurityApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ActivitiSpringSecurityApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SpringProcessEngineConfiguration processEngineConfiguration;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JdbcUserDetailsManager userManager;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
InitializingBean processEngineInitializer() {
|
||||||
|
return new InitializingBean() {
|
||||||
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
processEngineConfiguration.setUserEntityManager(new SpringSecurityUserManager(processEngineConfiguration, new MybatisUserDataManager(processEngineConfiguration), userManager));
|
||||||
|
processEngineConfiguration.setGroupEntityManager(new SpringSecurityGroupManager(processEngineConfiguration, new MybatisGroupDataManager(processEngineConfiguration)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.baeldung.activiti.security.withspring;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
import org.springframework.security.provisioning.JdbcUserDetailsManager;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataSource dataSource;
|
||||||
|
|
||||||
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
http.antMatcher("/**")
|
||||||
|
.authorizeRequests()
|
||||||
|
.antMatchers("/protected-process*")
|
||||||
|
.authenticated()
|
||||||
|
.anyRequest()
|
||||||
|
.permitAll()
|
||||||
|
.and()
|
||||||
|
.formLogin()
|
||||||
|
.loginPage("/login")
|
||||||
|
.defaultSuccessUrl("/homepage")
|
||||||
|
.failureUrl("/login?error=true")
|
||||||
|
.and()
|
||||||
|
.csrf()
|
||||||
|
.disable()
|
||||||
|
.logout()
|
||||||
|
.logoutSuccessUrl("/login");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public JdbcUserDetailsManager userDetailsManager() {
|
||||||
|
JdbcUserDetailsManager manager = new JdbcUserDetailsManager();
|
||||||
|
manager.setDataSource(dataSource);
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||||
|
auth.userDetailsService(userDetailsManager());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
3
spring-activiti/src/main/resources/data.sql
Normal file
3
spring-activiti/src/main/resources/data.sql
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
insert into users(username, password, enabled) values ('spring_user', 'pass', true);
|
||||||
|
|
||||||
|
insert into authorities(username, authority) values ('spring_user','ROLE_USER');
|
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef" xmlns:modeler="http://activiti.com/modeler" modeler:version="1.0ev" modeler:exportDateTime="20170726123124" modeler:modelId="1005315" modeler:modelVersion="1" modeler:modelLastUpdated="1501068675875">
|
||||||
|
<process id="protected-process" name="protected-process" isExecutable="true">
|
||||||
|
<startEvent id="startEvent" name="startEvent">
|
||||||
|
</startEvent>
|
||||||
|
<sequenceFlow id="sequence-flow-1" sourceRef="startEvent" targetRef="A">
|
||||||
|
</sequenceFlow>
|
||||||
|
<userTask id="A" name="A">
|
||||||
|
<potentialOwner>
|
||||||
|
<resourceAssignmentExpression>
|
||||||
|
<formalExpression>ROLE_USER</formalExpression>
|
||||||
|
</resourceAssignmentExpression>
|
||||||
|
</potentialOwner>
|
||||||
|
</userTask>
|
||||||
|
<sequenceFlow id="sequence-flow-2" sourceRef="A" targetRef="endEvent">
|
||||||
|
</sequenceFlow>
|
||||||
|
<endEvent id="endEvent" name="endEvent">
|
||||||
|
</endEvent>
|
||||||
|
</process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_protected-process">
|
||||||
|
<bpmndi:BPMNPlane bpmnElement="protected-process" id="BPMNPlane_protected-process">
|
||||||
|
<bpmndi:BPMNShape bpmnElement="startEvent" id="BPMNShape_startEvent">
|
||||||
|
<omgdc:Bounds height="30.0" width="30.0" x="120.0" y="163.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape bpmnElement="endEvent" id="BPMNShape_endEvent">
|
||||||
|
<omgdc:Bounds height="28.0" width="28.0" x="365.0" y="164.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape bpmnElement="A" id="BPMNShape_A">
|
||||||
|
<omgdc:Bounds height="80.0" width="100.0" x="210.0" y="138.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge bpmnElement="sequence-flow-1" id="BPMNEdge_sequence-flow-1">
|
||||||
|
<omgdi:waypoint x="150.0" y="178.0"/>
|
||||||
|
<omgdi:waypoint x="210.0" y="178.0"/>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNEdge bpmnElement="sequence-flow-2" id="BPMNEdge_sequence-flow-2">
|
||||||
|
<omgdi:waypoint x="310.0" y="178.0"/>
|
||||||
|
<omgdi:waypoint x="365.0" y="178.0"/>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</definitions>
|
3
spring-activiti/src/main/resources/schema.sql
Normal file
3
spring-activiti/src/main/resources/schema.sql
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
create table users(username varchar(255), password varchar(255), enabled boolean);
|
||||||
|
|
||||||
|
create table authorities(username varchar(255),authority varchar(255));
|
21
spring-activiti/src/main/resources/templates/login.html
Normal file
21
spring-activiti/src/main/resources/templates/login.html
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<html>
|
||||||
|
<head></head>
|
||||||
|
<body>
|
||||||
|
<h1>Login</h1>
|
||||||
|
<form name='f' action="login" method='POST'>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>User:</td>
|
||||||
|
<td><input type='text' name='username' value=''/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Password:</td>
|
||||||
|
<td><input type='password' name='password' /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><input name="submit" type="submit" value="submit" /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.example.activitiwithspring;
|
||||||
|
|
||||||
|
import org.activiti.engine.IdentityService;
|
||||||
|
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.security.core.userdetails.UsernameNotFoundException;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
|
|
||||||
|
import com.baeldung.activiti.security.withspring.ActivitiSpringSecurityApplication;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(classes = ActivitiSpringSecurityApplication.class)
|
||||||
|
@WebAppConfiguration
|
||||||
|
public class ActivitiSpringSecurityIntegrationTest {
|
||||||
|
@Autowired
|
||||||
|
private IdentityService identityService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenUserExists_thenOk() {
|
||||||
|
identityService.setUserPicture("spring_user", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = UsernameNotFoundException.class)
|
||||||
|
public void whenUserNonExistent_thenSpringException() {
|
||||||
|
identityService.setUserPicture("user3", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -16,10 +16,10 @@ import java.time.Month;
|
|||||||
@EnableAspectJAutoProxy
|
@EnableAspectJAutoProxy
|
||||||
public class AopConfiguration {
|
public class AopConfiguration {
|
||||||
|
|
||||||
@Pointcut("execution(public String com.baeldung.performancemonitor.PersonService.getFullName(..))")
|
@Pointcut("execution(public String org.baeldung.performancemonitor.PersonService.getFullName(..))")
|
||||||
public void monitor() { }
|
public void monitor() { }
|
||||||
|
|
||||||
@Pointcut("execution(public int com.baeldung.performancemonitor.PersonService.getAge(..))")
|
@Pointcut("execution(public int org.baeldung.performancemonitor.PersonService.getAge(..))")
|
||||||
public void myMonitor() { }
|
public void myMonitor() { }
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ -30,7 +30,7 @@ public class AopConfiguration {
|
|||||||
@Bean
|
@Bean
|
||||||
public Advisor performanceMonitorAdvisor() {
|
public Advisor performanceMonitorAdvisor() {
|
||||||
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
||||||
pointcut.setExpression("com.baeldung.performancemonitor.AopConfiguration.monitor()");
|
pointcut.setExpression("org.baeldung.performancemonitor.AopConfiguration.monitor()");
|
||||||
return new DefaultPointcutAdvisor(pointcut, performanceMonitorInterceptor());
|
return new DefaultPointcutAdvisor(pointcut, performanceMonitorInterceptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ public class AopConfiguration {
|
|||||||
@Bean
|
@Bean
|
||||||
public Advisor myPerformanceMonitorAdvisor() {
|
public Advisor myPerformanceMonitorAdvisor() {
|
||||||
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
||||||
pointcut.setExpression("com.baeldung.performancemonitor.AopConfiguration.myMonitor()");
|
pointcut.setExpression("org.baeldung.performancemonitor.AopConfiguration.myMonitor()");
|
||||||
return new DefaultPointcutAdvisor(pointcut, myPerformanceMonitorInterceptor());
|
return new DefaultPointcutAdvisor(pointcut, myPerformanceMonitorInterceptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1,17 @@
|
|||||||
Spring Boot Admin
|
## 1. Spring Boot Admin Server
|
||||||
|
|
||||||
|
* mvn clean install
|
||||||
|
* mvn spring-boot:run
|
||||||
|
* starts on port 8080
|
||||||
|
* login with admin/admin
|
||||||
|
* to activate mail notifications uncomment the starter mail dependency
|
||||||
|
and the mail configuration from application.properties
|
||||||
|
* add some real credentials if you want the app to send emails
|
||||||
|
* to activate Hipchat notifications proceed same as for email
|
||||||
|
|
||||||
|
## 2. Spring Boot App Client
|
||||||
|
|
||||||
|
* mvn clean install
|
||||||
|
* mvn spring-boot:run
|
||||||
|
* starts on port 8081
|
||||||
|
* basic auth client/client
|
36
spring-boot-admin/pom.xml
Normal file
36
spring-boot-admin/pom.xml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>spring-boot-admin</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-modules</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<spring.boot.version>1.5.8.RELEASE</spring.boot.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>spring-boot-admin-server</module>
|
||||||
|
<module>spring-boot-admin-client</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${spring.boot.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
</project>
|
@ -3,19 +3,18 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>spring-boot-admin-client</artifactId>
|
<artifactId>spring-boot-admin-client</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>spring-boot-admin-client</name>
|
<name>spring-boot-admin-client</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>Spring Boot Admin Client</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<artifactId>spring-boot-admin</artifactId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>1.5.8.RELEASE</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath>../../spring-boot-admin</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -3,19 +3,18 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>spring-boot-admin-server</artifactId>
|
<artifactId>spring-boot-admin-server</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>spring-boot-admin-server</name>
|
<name>spring-boot-admin-server</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>Spring Boot Admin Server</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<artifactId>spring-boot-admin</artifactId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>1.5.8.RELEASE</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath>../../spring-boot-admin</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
24
spring-boot-keycloak/.gitignore
vendored
Normal file
24
spring-boot-keycloak/.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
nbproject/private/
|
||||||
|
build/
|
||||||
|
nbbuild/
|
||||||
|
dist/
|
||||||
|
nbdist/
|
||||||
|
.nb-gradle/
|
BIN
spring-boot-keycloak/.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
BIN
spring-boot-keycloak/.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
Binary file not shown.
1
spring-boot-keycloak/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
1
spring-boot-keycloak/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip
|
225
spring-boot-keycloak/mvnw
vendored
Executable file
225
spring-boot-keycloak/mvnw
vendored
Executable file
@ -0,0 +1,225 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Maven2 Start Up Batch script
|
||||||
|
#
|
||||||
|
# Required ENV vars:
|
||||||
|
# ------------------
|
||||||
|
# JAVA_HOME - location of a JDK home dir
|
||||||
|
#
|
||||||
|
# Optional ENV vars
|
||||||
|
# -----------------
|
||||||
|
# M2_HOME - location of maven2's installed home dir
|
||||||
|
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||||
|
# e.g. to debug Maven itself, use
|
||||||
|
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||||
|
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||||
|
|
||||||
|
if [ -f /etc/mavenrc ] ; then
|
||||||
|
. /etc/mavenrc
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$HOME/.mavenrc" ] ; then
|
||||||
|
. "$HOME/.mavenrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# OS specific support. $var _must_ be set to either true or false.
|
||||||
|
cygwin=false;
|
||||||
|
darwin=false;
|
||||||
|
mingw=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN*) cygwin=true ;;
|
||||||
|
MINGW*) mingw=true;;
|
||||||
|
Darwin*) darwin=true
|
||||||
|
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||||
|
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||||
|
if [ -z "$JAVA_HOME" ]; then
|
||||||
|
if [ -x "/usr/libexec/java_home" ]; then
|
||||||
|
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||||
|
else
|
||||||
|
export JAVA_HOME="/Library/Java/Home"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ] ; then
|
||||||
|
if [ -r /etc/gentoo-release ] ; then
|
||||||
|
JAVA_HOME=`java-config --jre-home`
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$M2_HOME" ] ; then
|
||||||
|
## resolve links - $0 may be a link to maven's home
|
||||||
|
PRG="$0"
|
||||||
|
|
||||||
|
# need this for relative symlinks
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG="`dirname "$PRG"`/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
saveddir=`pwd`
|
||||||
|
|
||||||
|
M2_HOME=`dirname "$PRG"`/..
|
||||||
|
|
||||||
|
# make it fully qualified
|
||||||
|
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||||
|
|
||||||
|
cd "$saveddir"
|
||||||
|
# echo Using m2 at $M2_HOME
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||||
|
if $cygwin ; then
|
||||||
|
[ -n "$M2_HOME" ] &&
|
||||||
|
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||||
|
[ -n "$CLASSPATH" ] &&
|
||||||
|
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Migwn, ensure paths are in UNIX format before anything is touched
|
||||||
|
if $mingw ; then
|
||||||
|
[ -n "$M2_HOME" ] &&
|
||||||
|
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||||
|
# TODO classpath?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ]; then
|
||||||
|
javaExecutable="`which javac`"
|
||||||
|
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||||
|
# readlink(1) is not available as standard on Solaris 10.
|
||||||
|
readLink=`which readlink`
|
||||||
|
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||||
|
if $darwin ; then
|
||||||
|
javaHome="`dirname \"$javaExecutable\"`"
|
||||||
|
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||||
|
else
|
||||||
|
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||||
|
fi
|
||||||
|
javaHome="`dirname \"$javaExecutable\"`"
|
||||||
|
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||||
|
JAVA_HOME="$javaHome"
|
||||||
|
export JAVA_HOME
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVACMD" ] ; then
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="`which java`"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||||
|
echo " We cannot execute $JAVACMD" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ] ; then
|
||||||
|
echo "Warning: JAVA_HOME environment variable is not set."
|
||||||
|
fi
|
||||||
|
|
||||||
|
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||||
|
|
||||||
|
# traverses directory structure from process work directory to filesystem root
|
||||||
|
# first directory with .mvn subdirectory is considered project base directory
|
||||||
|
find_maven_basedir() {
|
||||||
|
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo "Path not specified to find_maven_basedir"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
basedir="$1"
|
||||||
|
wdir="$1"
|
||||||
|
while [ "$wdir" != '/' ] ; do
|
||||||
|
if [ -d "$wdir"/.mvn ] ; then
|
||||||
|
basedir=$wdir
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||||
|
if [ -d "${wdir}" ]; then
|
||||||
|
wdir=`cd "$wdir/.."; pwd`
|
||||||
|
fi
|
||||||
|
# end of workaround
|
||||||
|
done
|
||||||
|
echo "${basedir}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# concatenates all lines of a file
|
||||||
|
concat_lines() {
|
||||||
|
if [ -f "$1" ]; then
|
||||||
|
echo "$(tr -s '\n' ' ' < "$1")"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||||
|
if [ -z "$BASE_DIR" ]; then
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||||
|
echo $MAVEN_PROJECTBASEDIR
|
||||||
|
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin; then
|
||||||
|
[ -n "$M2_HOME" ] &&
|
||||||
|
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||||
|
[ -n "$CLASSPATH" ] &&
|
||||||
|
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||||
|
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||||
|
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
|
exec "$JAVACMD" \
|
||||||
|
$MAVEN_OPTS \
|
||||||
|
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||||
|
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||||
|
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
143
spring-boot-keycloak/mvnw.cmd
vendored
Normal file
143
spring-boot-keycloak/mvnw.cmd
vendored
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@REM or more contributor license agreements. See the NOTICE file
|
||||||
|
@REM distributed with this work for additional information
|
||||||
|
@REM regarding copyright ownership. The ASF licenses this file
|
||||||
|
@REM to you under the Apache License, Version 2.0 (the
|
||||||
|
@REM "License"); you may not use this file except in compliance
|
||||||
|
@REM with the License. You may obtain a copy of the License at
|
||||||
|
@REM
|
||||||
|
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@REM
|
||||||
|
@REM Unless required by applicable law or agreed to in writing,
|
||||||
|
@REM software distributed under the License is distributed on an
|
||||||
|
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
@REM KIND, either express or implied. See the License for the
|
||||||
|
@REM specific language governing permissions and limitations
|
||||||
|
@REM under the License.
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Maven2 Start Up Batch script
|
||||||
|
@REM
|
||||||
|
@REM Required ENV vars:
|
||||||
|
@REM JAVA_HOME - location of a JDK home dir
|
||||||
|
@REM
|
||||||
|
@REM Optional ENV vars
|
||||||
|
@REM M2_HOME - location of maven2's installed home dir
|
||||||
|
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||||
|
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||||
|
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||||
|
@REM e.g. to debug Maven itself, use
|
||||||
|
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||||
|
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||||
|
@echo off
|
||||||
|
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||||
|
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||||
|
|
||||||
|
@REM set %HOME% to equivalent of $HOME
|
||||||
|
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||||
|
|
||||||
|
@REM Execute a user defined script before this one
|
||||||
|
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||||
|
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||||
|
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||||
|
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||||
|
:skipRcPre
|
||||||
|
|
||||||
|
@setlocal
|
||||||
|
|
||||||
|
set ERROR_CODE=0
|
||||||
|
|
||||||
|
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||||
|
@setlocal
|
||||||
|
|
||||||
|
@REM ==== START VALIDATION ====
|
||||||
|
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Error: JAVA_HOME not found in your environment. >&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||||
|
echo location of your Java installation. >&2
|
||||||
|
echo.
|
||||||
|
goto error
|
||||||
|
|
||||||
|
:OkJHome
|
||||||
|
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||||
|
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||||
|
echo location of your Java installation. >&2
|
||||||
|
echo.
|
||||||
|
goto error
|
||||||
|
|
||||||
|
@REM ==== END VALIDATION ====
|
||||||
|
|
||||||
|
:init
|
||||||
|
|
||||||
|
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||||
|
@REM Fallback to current working directory if not found.
|
||||||
|
|
||||||
|
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||||
|
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||||
|
|
||||||
|
set EXEC_DIR=%CD%
|
||||||
|
set WDIR=%EXEC_DIR%
|
||||||
|
:findBaseDir
|
||||||
|
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||||
|
cd ..
|
||||||
|
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||||
|
set WDIR=%CD%
|
||||||
|
goto findBaseDir
|
||||||
|
|
||||||
|
:baseDirFound
|
||||||
|
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||||
|
cd "%EXEC_DIR%"
|
||||||
|
goto endDetectBaseDir
|
||||||
|
|
||||||
|
:baseDirNotFound
|
||||||
|
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||||
|
cd "%EXEC_DIR%"
|
||||||
|
|
||||||
|
:endDetectBaseDir
|
||||||
|
|
||||||
|
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||||
|
|
||||||
|
@setlocal EnableExtensions EnableDelayedExpansion
|
||||||
|
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||||
|
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||||
|
|
||||||
|
:endReadAdditionalConfig
|
||||||
|
|
||||||
|
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||||
|
|
||||||
|
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||||
|
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
|
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||||
|
if ERRORLEVEL 1 goto error
|
||||||
|
goto end
|
||||||
|
|
||||||
|
:error
|
||||||
|
set ERROR_CODE=1
|
||||||
|
|
||||||
|
:end
|
||||||
|
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||||
|
|
||||||
|
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||||
|
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||||
|
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||||
|
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||||
|
:skipRcPost
|
||||||
|
|
||||||
|
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||||
|
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||||
|
|
||||||
|
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||||
|
|
||||||
|
exit /B %ERROR_CODE%
|
86
spring-boot-keycloak/pom.xml
Normal file
86
spring-boot-keycloak/pom.xml
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.baeldung.keycloak</groupId>
|
||||||
|
<artifactId>spring-boot-keycloak</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>spring-boot-keycloak</name>
|
||||||
|
<description>This is a simple application demonstrating integration between Keycloak and Spring Boot.</description>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>1.5.8.RELEASE</version>
|
||||||
|
<relativePath /> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hsqldb</groupId>
|
||||||
|
<artifactId>hsqldb</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak.bom</groupId>
|
||||||
|
<artifactId>keycloak-adapter-bom</artifactId>
|
||||||
|
<version>3.3.0.Final</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
@ -17,26 +17,33 @@ public class Customer {
|
|||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(long id) {
|
public void setId(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServiceRendered() {
|
public String getServiceRendered() {
|
||||||
return serviceRendered;
|
return serviceRendered;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServiceRendered(String serviceRendered) {
|
public void setServiceRendered(String serviceRendered) {
|
||||||
this.serviceRendered = serviceRendered;
|
this.serviceRendered = serviceRendered;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAddress() {
|
public String getAddress() {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAddress(String address) {
|
public void setAddress(String address) {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,15 +3,12 @@ package com.baeldung.keycloak;
|
|||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
import com.baeldung.autoconfiguration.MySQLAutoconfiguration;
|
|
||||||
|
|
||||||
@SpringBootApplication(exclude = MySQLAutoconfiguration.class)
|
|
||||||
|
|
||||||
public class SpringBoot {
|
public class SpringBoot {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(SpringBoot.class, args);
|
SpringApplication.run(SpringBoot.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
#Keycloak Configuration
|
||||||
|
keycloak.auth-server-url=http://localhost:8180/auth
|
||||||
|
keycloak.realm=SpringBootKeycloak
|
||||||
|
keycloak.resource=login-app
|
||||||
|
keycloak.public-client=true
|
||||||
|
keycloak.principal-attribute=preferred_username
|
@ -0,0 +1,33 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head th:include="layout :: headerFragment">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="container">
|
||||||
|
<h1>
|
||||||
|
Hello, <span th:text="${username}">--name--</span>.
|
||||||
|
</h1>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Address</th>
|
||||||
|
<th>Service Rendered</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="customer : ${customers}">
|
||||||
|
<td th:text="${customer.id}">Text ...</td>
|
||||||
|
<td th:text="${customer.name}">Text ...</td>
|
||||||
|
<td th:text="${customer.address}">Text ...</td>
|
||||||
|
<td th:text="${customer.serviceRendered}">Text...</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div id="pagefoot" th:include="layout :: footerFragment">Footer
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- container -->
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,31 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head th:include="layout :: headerFragment">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="jumbotron text-center">
|
||||||
|
<h1>Customer Portal</h1>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam
|
||||||
|
erat lectus, vehicula feugiat ultricies at, tempus sed ante. Cras
|
||||||
|
arcu erat, lobortis vitae quam et, mollis pharetra odio. Nullam sit
|
||||||
|
amet congue ipsum. Nunc dapibus odio ut ligula venenatis porta non
|
||||||
|
id dui. Duis nec tempor tellus. Suspendisse id blandit ligula, sit
|
||||||
|
amet varius mauris. Nulla eu eros pharetra, tristique dui quis,
|
||||||
|
vehicula libero. Aenean a neque sit amet tellus porttitor rutrum nec
|
||||||
|
at leo.</p>
|
||||||
|
|
||||||
|
<h2>Existing Customers</h2>
|
||||||
|
<div class="well">
|
||||||
|
<b>Enter the intranet: </b><a th:href="@{/customers}">customers</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="pagefoot" th:include="layout :: footerFragment">Footer
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- container -->
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
<head th:fragment="headerFragment">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<title>Customer Portal</title>
|
||||||
|
<link
|
||||||
|
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
|
||||||
|
rel="stylesheet"
|
||||||
|
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
|
||||||
|
crossorigin="anonymous"></link>
|
||||||
|
<link
|
||||||
|
href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"
|
||||||
|
rel="stylesheet"></link>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<div id="pagefoot" th:fragment="footerFragment">
|
||||||
|
<p>Document last modified 2017/10/23.</p>
|
||||||
|
<p>Copyright: Lorem Ipsum</p>
|
||||||
|
</div>
|
@ -1,6 +1,5 @@
|
|||||||
package com.baeldung.keycloak;
|
package com.baeldung.keycloak;
|
||||||
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
@ -24,10 +24,6 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak</groupId>
|
|
||||||
<artifactId>keycloak-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
@ -76,7 +72,6 @@
|
|||||||
<artifactId>tomcat-embed-core</artifactId>
|
<artifactId>tomcat-embed-core</artifactId>
|
||||||
<version>${tomcat.version}</version>
|
<version>${tomcat.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
<groupId>org.apache.tomcat.embed</groupId>
|
||||||
<artifactId>tomcat-embed-jasper</artifactId>
|
<artifactId>tomcat-embed-jasper</artifactId>
|
||||||
@ -173,17 +168,6 @@
|
|||||||
<artifactId>artemis-server</artifactId>
|
<artifactId>artemis-server</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak.bom</groupId>
|
|
||||||
<artifactId>keycloak-adapter-bom</artifactId>
|
|
||||||
<version>3.3.0.CR2</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>spring-boot</finalName>
|
<finalName>spring-boot</finalName>
|
||||||
@ -283,7 +267,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- The main class to start by executing java -jar -->
|
<!-- The main class to start by executing java -jar -->
|
||||||
<start-class>org.baeldung.boot.DemoApplication</start-class>
|
<start-class>org.baeldung.demo.DemoApplication</start-class>
|
||||||
<spring.version>4.3.4.RELEASE</spring.version>
|
<spring.version>4.3.4.RELEASE</spring.version>
|
||||||
<git-commit-id-plugin.version>2.2.1</git-commit-id-plugin.version>
|
<git-commit-id-plugin.version>2.2.1</git-commit-id-plugin.version>
|
||||||
<jquery.version>3.1.1</jquery.version>
|
<jquery.version>3.1.1</jquery.version>
|
||||||
@ -294,4 +278,4 @@
|
|||||||
<togglz.version>2.4.1.Final</togglz.version>
|
<togglz.version>2.4.1.Final</togglz.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung;
|
package org.baeldung.boot;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.client;
|
package org.baeldung.boot.client;
|
||||||
|
|
||||||
public class Details {
|
public class Details {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.client;
|
package org.baeldung.boot.client;
|
||||||
|
|
||||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.config;
|
package org.baeldung.boot.config;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
|||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableJpaRepositories(basePackages = { "org.baeldung.repository", "org.baeldung.boot.repository", "org.baeldung.boot.boottest" })
|
@EnableJpaRepositories(basePackages = { "org.baeldung.boot.repository", "org.baeldung.boot.boottest","org.baeldung.repository" })
|
||||||
@PropertySource("classpath:persistence-generic-entity.properties")
|
@PropertySource("classpath:persistence-generic-entity.properties")
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
public class H2JpaConfig {
|
public class H2JpaConfig {
|
||||||
@ -41,7 +41,7 @@ public class H2JpaConfig {
|
|||||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||||
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
||||||
em.setDataSource(dataSource());
|
em.setDataSource(dataSource());
|
||||||
em.setPackagesToScan(new String[] { "org.baeldung.domain", "org.baeldung.boot.model", "org.baeldung.boot.boottest" });
|
em.setPackagesToScan(new String[] { "org.baeldung.boot.domain", "org.baeldung.boot.model", "org.baeldung.boot.boottest", "org.baeldung.model" });
|
||||||
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
|
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
|
||||||
em.setJpaProperties(additionalProperties());
|
em.setJpaProperties(additionalProperties());
|
||||||
return em;
|
return em;
|
@ -1,9 +1,9 @@
|
|||||||
package org.baeldung.config;
|
package org.baeldung.boot.config;
|
||||||
|
|
||||||
import org.baeldung.converter.GenericBigDecimalConverter;
|
import org.baeldung.boot.converter.GenericBigDecimalConverter;
|
||||||
import org.baeldung.converter.StringToEnumConverterFactory;
|
import org.baeldung.boot.converter.StringToEmployeeConverter;
|
||||||
import org.baeldung.converter.StringToEmployeeConverter;
|
import org.baeldung.boot.converter.StringToEnumConverterFactory;
|
||||||
import org.baeldung.web.resolver.HeaderVersionArgumentResolver;
|
import org.baeldung.boot.web.resolver.HeaderVersionArgumentResolver;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.format.FormatterRegistry;
|
import org.springframework.format.FormatterRegistry;
|
||||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
@ -1,8 +1,8 @@
|
|||||||
package org.baeldung.controller;
|
package org.baeldung.boot.controller;
|
||||||
|
|
||||||
import org.baeldung.domain.GenericEntity;
|
import org.baeldung.boot.domain.GenericEntity;
|
||||||
import org.baeldung.domain.Modes;
|
import org.baeldung.boot.domain.Modes;
|
||||||
import org.baeldung.web.resolver.Version;
|
import org.baeldung.boot.web.resolver.Version;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
@ -1,43 +1,43 @@
|
|||||||
package org.baeldung.controller.servlet;
|
package org.baeldung.boot.controller.servlet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
public class HelloWorldServlet extends HttpServlet {
|
public class HelloWorldServlet extends HttpServlet {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public HelloWorldServlet() {
|
public HelloWorldServlet() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
PrintWriter out = null;
|
PrintWriter out = null;
|
||||||
try {
|
try {
|
||||||
out = response.getWriter();
|
out = response.getWriter();
|
||||||
out.println("HelloWorldServlet: GET METHOD");
|
out.println("HelloWorldServlet: GET METHOD");
|
||||||
out.flush();
|
out.flush();
|
||||||
} finally {
|
} finally {
|
||||||
if (!Objects.isNull(out))
|
if (!Objects.isNull(out))
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
PrintWriter out = null;
|
PrintWriter out = null;
|
||||||
try {
|
try {
|
||||||
out = response.getWriter();
|
out = response.getWriter();
|
||||||
out.println("HelloWorldServlet: POST METHOD");
|
out.println("HelloWorldServlet: POST METHOD");
|
||||||
out.flush();
|
out.flush();
|
||||||
} finally {
|
} finally {
|
||||||
if (!Objects.isNull(out))
|
if (!Objects.isNull(out))
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,43 +1,43 @@
|
|||||||
package org.baeldung.controller.servlet;
|
package org.baeldung.boot.controller.servlet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
public class SpringHelloWorldServlet extends HttpServlet {
|
public class SpringHelloWorldServlet extends HttpServlet {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public SpringHelloWorldServlet() {
|
public SpringHelloWorldServlet() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
PrintWriter out = null;
|
PrintWriter out = null;
|
||||||
try {
|
try {
|
||||||
out = response.getWriter();
|
out = response.getWriter();
|
||||||
out.println("SpringHelloWorldServlet: GET METHOD");
|
out.println("SpringHelloWorldServlet: GET METHOD");
|
||||||
out.flush();
|
out.flush();
|
||||||
} finally {
|
} finally {
|
||||||
if (!Objects.isNull(out))
|
if (!Objects.isNull(out))
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
PrintWriter out = null;
|
PrintWriter out = null;
|
||||||
try {
|
try {
|
||||||
out = response.getWriter();
|
out = response.getWriter();
|
||||||
out.println("SpringHelloWorldServlet: POST METHOD");
|
out.println("SpringHelloWorldServlet: POST METHOD");
|
||||||
out.flush();
|
out.flush();
|
||||||
} finally {
|
} finally {
|
||||||
if (!Objects.isNull(out))
|
if (!Objects.isNull(out))
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.converter;
|
package org.baeldung.boot.converter;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.springframework.core.convert.TypeDescriptor;
|
import org.springframework.core.convert.TypeDescriptor;
|
||||||
@ -35,4 +35,4 @@ public class GenericBigDecimalConverter implements GenericConverter {
|
|||||||
return converted.setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
return converted.setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.converter;
|
package org.baeldung.boot.converter;
|
||||||
|
|
||||||
|
|
||||||
import com.baeldung.toggle.Employee;
|
import com.baeldung.toggle.Employee;
|
||||||
@ -11,4 +11,4 @@ public class StringToEmployeeConverter implements Converter<String, Employee> {
|
|||||||
String[] data = from.split(",");
|
String[] data = from.split(",");
|
||||||
return new Employee(Long.parseLong(data[0]), Double.parseDouble(data[1]));
|
return new Employee(Long.parseLong(data[0]), Double.parseDouble(data[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.converter;
|
package org.baeldung.boot.converter;
|
||||||
|
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.core.convert.converter.ConverterFactory;
|
import org.springframework.core.convert.converter.ConverterFactory;
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.converter;
|
package org.baeldung.boot.converter;
|
||||||
|
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
@ -0,0 +1,16 @@
|
|||||||
|
package org.baeldung.boot.converter.controller;
|
||||||
|
|
||||||
|
import com.baeldung.toggle.Employee;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/string-to-employee")
|
||||||
|
public class StringToEmployeeConverterController {
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public ResponseEntity<Object> getStringToEmployee(@RequestParam("employee") Employee employee) {
|
||||||
|
return ResponseEntity.ok(employee);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.domain;
|
package org.baeldung.boot.domain;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.domain;
|
package org.baeldung.boot.domain;
|
||||||
|
|
||||||
public enum Modes {
|
public enum Modes {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.jsoncomponent;
|
package org.baeldung.boot.jsoncomponent;
|
||||||
|
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.jsoncomponent;
|
package org.baeldung.boot.jsoncomponent;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
import com.fasterxml.jackson.core.JsonParser;
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.jsoncomponent;
|
package org.baeldung.boot.jsoncomponent;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.jsoncomponent;
|
package org.baeldung.boot.jsoncomponent;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
@ -1,22 +1,22 @@
|
|||||||
package org.baeldung.monitor.jmx;
|
package org.baeldung.boot.monitor.jmx;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import com.codahale.metrics.JmxReporter;
|
import com.codahale.metrics.JmxReporter;
|
||||||
import com.codahale.metrics.MetricRegistry;
|
import com.codahale.metrics.MetricRegistry;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class MonitoringConfig {
|
public class MonitoringConfig {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MetricRegistry registry;
|
private MetricRegistry registry;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public JmxReporter jmxReporter() {
|
public JmxReporter jmxReporter() {
|
||||||
JmxReporter reporter = JmxReporter.forRegistry(registry)
|
JmxReporter reporter = JmxReporter.forRegistry(registry)
|
||||||
.build();
|
.build();
|
||||||
reporter.start();
|
reporter.start();
|
||||||
return reporter;
|
return reporter;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package org.baeldung.repository;
|
package org.baeldung.boot.repository;
|
||||||
|
|
||||||
import org.baeldung.domain.GenericEntity;
|
import org.baeldung.boot.domain.GenericEntity;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
public interface GenericEntityRepository extends JpaRepository<GenericEntity, Long> {
|
public interface GenericEntityRepository extends JpaRepository<GenericEntity, Long> {
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.web.resolver;
|
package org.baeldung.boot.web.resolver;
|
||||||
|
|
||||||
import org.springframework.core.MethodParameter;
|
import org.springframework.core.MethodParameter;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.web.resolver;
|
package org.baeldung.boot.web.resolver;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.boot;
|
package org.baeldung.demo;
|
||||||
|
|
||||||
import com.baeldung.graphql.GraphqlConfiguration;
|
import com.baeldung.graphql.GraphqlConfiguration;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.boot.boottest;
|
package org.baeldung.demo.boottest;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.boot.boottest;
|
package org.baeldung.demo.boottest;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.boot.boottest;
|
package org.baeldung.demo.boottest;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.boot.boottest;
|
package org.baeldung.demo.boottest;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.boot.boottest;
|
package org.baeldung.demo.boottest;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package org.baeldung.boot.components;
|
package org.baeldung.demo.components;
|
||||||
|
|
||||||
import org.baeldung.boot.model.Foo;
|
import org.baeldung.demo.model.Foo;
|
||||||
import org.baeldung.boot.repository.FooRepository;
|
import org.baeldung.demo.repository.FooRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.boot.exceptions;
|
package org.baeldung.demo.exceptions;
|
||||||
|
|
||||||
public class CommonException extends RuntimeException {
|
public class CommonException extends RuntimeException {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.boot.exceptions;
|
package org.baeldung.demo.exceptions;
|
||||||
|
|
||||||
public class FooNotFoundException extends RuntimeException {
|
public class FooNotFoundException extends RuntimeException {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.boot.model;
|
package org.baeldung.demo.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
package org.baeldung.boot.repository;
|
package org.baeldung.demo.repository;
|
||||||
|
|
||||||
import org.baeldung.boot.model.Foo;
|
import org.baeldung.demo.model.Foo;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
public interface FooRepository extends JpaRepository<Foo, Integer> {
|
public interface FooRepository extends JpaRepository<Foo, Integer> {
|
@ -1,7 +1,7 @@
|
|||||||
package org.baeldung.boot.service;
|
package org.baeldung.demo.service;
|
||||||
|
|
||||||
import org.baeldung.boot.components.FooService;
|
import org.baeldung.demo.components.FooService;
|
||||||
import org.baeldung.boot.model.Foo;
|
import org.baeldung.demo.model.Foo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
@ -3,7 +3,7 @@ package org.baeldung.endpoints.info;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.baeldung.boot.repository.UserRepository;
|
import org.baeldung.repository.UserRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.actuate.info.Info;
|
import org.springframework.boot.actuate.info.Info;
|
||||||
import org.springframework.boot.actuate.info.InfoContributor;
|
import org.springframework.boot.actuate.info.InfoContributor;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package org.baeldung.main;
|
package org.baeldung.main;
|
||||||
|
|
||||||
|
import org.baeldung.boot.controller.servlet.HelloWorldServlet;
|
||||||
|
import org.baeldung.boot.controller.servlet.SpringHelloWorldServlet;
|
||||||
import org.baeldung.common.error.SpringHelloServletRegistrationBean;
|
import org.baeldung.common.error.SpringHelloServletRegistrationBean;
|
||||||
import org.baeldung.common.resources.ExecutorServiceExitCodeGenerator;
|
import org.baeldung.common.resources.ExecutorServiceExitCodeGenerator;
|
||||||
import org.baeldung.controller.servlet.HelloWorldServlet;
|
|
||||||
import org.baeldung.controller.servlet.SpringHelloWorldServlet;
|
|
||||||
import org.baeldung.service.LoginService;
|
import org.baeldung.service.LoginService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
@ -11,6 +11,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ import java.util.concurrent.Executors;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@EnableAutoConfiguration(exclude = MySQLAutoconfiguration.class)
|
@EnableAutoConfiguration(exclude = MySQLAutoconfiguration.class)
|
||||||
@ComponentScan({ "org.baeldung.common.error", "org.baeldung.common.error.controller", "org.baeldung.common.properties", "org.baeldung.common.resources", "org.baeldung.endpoints", "org.baeldung.service", "org.baeldung.monitor.jmx", "org.baeldung.service" })
|
@ComponentScan({ "org.baeldung.common.error", "org.baeldung.common.error.controller", "org.baeldung.common.properties", "org.baeldung.common.resources","org.baeldung.endpoints", "org.baeldung.service", "org.baeldung.monitor.jmx", "org.baeldung.boot.config"})
|
||||||
public class SpringBootApplication {
|
public class SpringBootApplication {
|
||||||
|
|
||||||
private static ApplicationContext applicationContext;
|
private static ApplicationContext applicationContext;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.boot.model;
|
package org.baeldung.model;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
@ -1,6 +1,6 @@
|
|||||||
package org.baeldung.boot.repository;
|
package org.baeldung.repository;
|
||||||
|
|
||||||
import org.baeldung.boot.model.User;
|
import org.baeldung.model.User;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
package org.baeldung.session.exception;
|
package org.baeldung.session.exception;
|
||||||
|
|
||||||
import org.baeldung.boot.model.Foo;
|
import org.baeldung.demo.model.Foo;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.baeldung.session.exception.repository;
|
package org.baeldung.session.exception.repository;
|
||||||
|
|
||||||
import org.baeldung.boot.model.Foo;
|
import org.baeldung.demo.model.Foo;
|
||||||
|
|
||||||
public interface FooRepository {
|
public interface FooRepository {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.baeldung.session.exception.repository;
|
package org.baeldung.session.exception.repository;
|
||||||
|
|
||||||
import org.baeldung.boot.model.Foo;
|
import org.baeldung.demo.model.Foo;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
|
@ -49,10 +49,3 @@ contactInfoType=email
|
|||||||
|
|
||||||
endpoints.beans.id=springbeans
|
endpoints.beans.id=springbeans
|
||||||
endpoints.beans.sensitive=false
|
endpoints.beans.sensitive=false
|
||||||
|
|
||||||
#Keycloak Configuration
|
|
||||||
keycloak.auth-server-url=http://localhost:8180/auth
|
|
||||||
keycloak.realm=SpringBootKeycloak
|
|
||||||
keycloak.resource=login-app
|
|
||||||
keycloak.public-client=true
|
|
||||||
keycloak.principal-attribute=preferred_username
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.baeldung;
|
package org.baeldung;
|
||||||
|
|
||||||
import org.baeldung.domain.Modes;
|
import org.baeldung.boot.Application;
|
||||||
|
import org.baeldung.boot.domain.Modes;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user