Merge branch 'master' of github.com:eugenp/tutorials into master

This commit is contained in:
Karsten Silz 2020-09-09 10:29:40 +01:00
commit 0a69454cf8
36 changed files with 122 additions and 127 deletions

View File

@ -22,6 +22,30 @@ fun main() {
numbers.each { println(random * it) } // capturing the random variable
}
fun namedFunction(): Int {
return 42
}
fun anonymous(): () -> Int {
return fun(): Int {
return 42
}
}
inline fun <T> List<T>.eachIndexed(f: (Int, T) -> Unit) {
for (i in indices) {
f(i, this[i])
}
}
fun <T> List<T>.indexOf(x: T): Int {
eachIndexed { index, value ->
if (value == x) return index
}
return -1
}
/**
* Generates a random number.
*/

View File

@ -8,9 +8,9 @@
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-spring-4</artifactId>
<artifactId>parent-spring-5</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-spring-4</relativePath>
<relativePath>../../parent-spring-5</relativePath>
</parent>
<dependencies>
@ -30,6 +30,31 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>

View File

@ -25,14 +25,6 @@
<version>${mongodb-driver.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>${spring-releasetrain}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-reactivestreams</artifactId>
@ -114,7 +106,6 @@
<mysema.maven.version>1.1.3</mysema.maven.version>
<mongodb-reactivestreams.version>4.1.0</mongodb-reactivestreams.version>
<projectreactor.version>3.2.0.RELEASE</projectreactor.version>
<spring-releasetrain>Lovelace-SR9</spring-releasetrain>
<mongodb-driver.version>4.0.5</mongodb-driver.version>
</properties>

View File

@ -81,7 +81,7 @@ public class MongoConfig extends AbstractMongoClientConfiguration {
@Bean
MongoTransactionManager transactionManager(MongoDatabaseFactory dbFactory) {
return new MongoTransactionManager(dbFactory);
return new MongoTransactionManager(dbFactory);
}
}

View File

@ -2,7 +2,6 @@ package com.baeldung.transaction;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.List;
@ -22,7 +21,6 @@ import org.springframework.transaction.annotation.Transactional;
import com.baeldung.config.MongoConfig;
import com.baeldung.model.User;
import com.baeldung.repository.UserRepository;
import com.mongodb.MongoCommandException;
/**
*

View File

@ -8,9 +8,9 @@
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-spring-4</artifactId>
<artifactId>parent-spring-5</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-spring-4</relativePath>
<relativePath>../../parent-spring-5</relativePath>
</parent>
<dependencies>

View File

@ -657,8 +657,6 @@
<module>spring-freemarker</module>
<module>spring-groovy</module>
<module>spring-integration</module>
<module>spring-jenkins-pipeline</module>
@ -1161,8 +1159,6 @@
<module>spring-freemarker</module>
<module>spring-groovy</module>
<module>spring-integration</module>
<module>spring-jenkins-pipeline</module>

View File

@ -1,3 +0,0 @@
### Relevant Articles:
- [Building a Simple Web Application with Spring Boot and Groovy](https://www.baeldung.com/spring-boot-groovy-web-app)

View File

@ -41,6 +41,7 @@
<module>spring-boot-environment</module>
<module>spring-boot-exceptions</module>
<module>spring-boot-flowable</module>
<module>spring-boot-groovy</module>
<!-- <module>spring-boot-gradle</module> --> <!-- Not a maven project -->
<module>spring-boot-jasypt</module>
<module>spring-boot-keycloak</module>

View File

@ -0,0 +1,9 @@
## Spring Boot Groovy
This module contains articles about Spring with Groovy
### Relevant Articles:
- [Building a Simple Web Application with Spring Boot and Groovy](https://www.baeldung.com/spring-boot-groovy-web-app)
- [Groovy Bean Definitions](https://www.baeldung.com/spring-groovy-beans)

View File

@ -14,7 +14,7 @@
<groupId>com.baeldung</groupId>
<artifactId>parent-boot-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2</relativePath>
<relativePath>../../parent-boot-2</relativePath>
</parent>
<dependencies>
@ -72,7 +72,7 @@
</build>
<properties>
<start-class>com.baeldung.app.SpringBootGroovyApplication</start-class>
<start-class>com.baeldung.springwithgroovy.SpringBootGroovyApplication</start-class>
</properties>
</project>

View File

@ -1,4 +1,4 @@
package com.baeldug.groovyconfig;
package com.baeldung.groovyconfig;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.baeldug.groovyconfig;
package com.baeldung.groovyconfig;
beans {
javaPesronBean(JavaPersonBean) {

View File

@ -1,4 +1,4 @@
package com.baeldug.groovyconfig;
package com.baeldung.groovyconfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

View File

@ -1,4 +1,4 @@
package com.baeldug.groovyconfig;
package com.baeldung.groovyconfig;
public class JavaPersonBean {

View File

@ -1,4 +1,4 @@
package com.baeldug.spring_groovy;
package com.baeldung.spring_groovy;
/**
* Hello world!

View File

@ -1,4 +1,4 @@
package com.baeldug.spring_groovy;
package com.baeldung.spring_groovy;
import org.springframework.stereotype.Component;

View File

@ -2,7 +2,7 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="JavaPersonBean" class="com.baeldug.groovyconfig.JavaPersonBean">
<bean id="JavaPersonBean" class="com.baeldung.groovyconfig.JavaPersonBean">
<property name="firstName" value="John" />
<property name="LastName" value="Doe" />
<property name="age" value="30" />

View File

@ -17,8 +17,11 @@ import com.baeldung.springwithgroovy.entity.Todo
import io.restassured.RestAssured
import io.restassured.response.Response
class TodoAppUnitTest {
static API_ROOT = 'http://localhost:8081/todo'
// This test requires the com.baeldung.springwithgroovy.SpringBootGroovyApplication to be up
// For that, run the maven build - spring-boot:run on the module
class TodoAppLiveTest {
static API_ROOT = 'http://localhost:8080/todo'
static readingTodoId
static writingTodoId

View File

@ -1,4 +1,4 @@
package com.baeldug.groovyconfig;
package com.baeldung.groovyconfig;
import static org.junit.Assert.assertEquals;
@ -7,10 +7,13 @@ import java.io.File;
import org.junit.Test;
import org.springframework.context.support.GenericGroovyApplicationContext;
import com.baeldung.groovyconfig.BandsBean;
import com.baeldung.groovyconfig.JavaPersonBean;
public class GroovyConfigurationUnitTest {
private static final String FILE_NAME = "GroovyBeanConfig.groovy";
private static final String FILE_PATH = "src/main/java/com/baeldug/groovyconfig/";
private static final String FILE_PATH = "src/main/java/com/baeldung/groovyconfig/";
@Test
public void whenGroovyConfig_thenCorrectPerson() throws Exception {

View File

@ -1,10 +1,13 @@
package com.baeldug.groovyconfig;
package com.baeldung.groovyconfig;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import com.baeldung.groovyconfig.JavaBeanConfig;
import com.baeldung.groovyconfig.JavaPersonBean;
public class JavaConfigurationUnitTest {
@Test

View File

@ -1,4 +1,4 @@
package com.baeldug.groovyconfig;
package com.baeldung.groovyconfig;
import static org.junit.Assert.*;
@ -6,6 +6,8 @@ import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.baeldung.groovyconfig.JavaPersonBean;
public class XmlConfigurationUnitTest {
@Test

View File

@ -1,4 +1,4 @@
package com.baeldug.spring_groovy;
package com.baeldung.spring_groovy;
import junit.framework.Test;
import junit.framework.TestCase;

View File

@ -8,8 +8,9 @@
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>parent-spring-5</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-spring-5</relativePath>
</parent>
<dependencies>
@ -40,17 +41,40 @@
<artifactId>kie-spring</artifactId>
<version>${drools-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring-framework.version}</version>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<drools-version>7.0.0.Final</drools-version>
<spring-framework.version>4.3.3.RELEASE</spring-framework.version>
</properties>
</project>

View File

@ -1,7 +0,0 @@
/target/
/project/
.classpath
.settings
.eclipse
.idea
.project

View File

@ -1,7 +0,0 @@
## Spring Groovy
This module contains articles about Spring with Groovy
## Relevant Articles:
- [Groovy Bean Definitions](https://www.baeldung.com/spring-groovy-beans)

View File

@ -1,67 +0,0 @@
<?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.baeldug</groupId>
<artifactId>spring-groovy</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-groovy</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-spring-4</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-spring-4</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-groovy</artifactId>
<version>${spring-integration-groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy-all.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<verbose>true</verbose>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>${groovy-eclipse-compiler.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>${groovy-eclipse-batch.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<properties>
<groovy-eclipse-compiler.version>2.9.2-01</groovy-eclipse-compiler.version>
<groovy-eclipse-batch.version>2.4.3-01</groovy-eclipse-batch.version>
<spring-integration-groovy.version>4.3.7.RELEASE</spring-integration-groovy.version>
<groovy-all.version>2.4.12</groovy-all.version>
</properties>
</project>