├── ai ├── README.md ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── ai │ │ │ └── AiApplicationTests.java │ └── main │ │ ├── resources │ │ ├── my-system-prompt.md │ │ ├── application.properties │ │ ├── schema.sql │ │ └── data.sql │ │ └── java │ │ └── com │ │ └── example │ │ └── ai │ │ └── AiApplication.java ├── compose.yaml ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── pom.xml └── mvnw.cmd ├── .gitignore ├── aot ├── src │ ├── main │ │ ├── resources │ │ │ ├── message │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── aot │ │ │ └── AotApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── aot │ │ └── AotApplicationTests.java ├── native.sh ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── pom.xml └── mvnw.cmd ├── microservices ├── config │ ├── service-a.properties │ ├── service-b.properties │ ├── application.properties │ └── .DS_Store ├── .DS_Store ├── service-a │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── service_a │ │ │ │ └── ServiceAApplication.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── service_a │ │ │ └── ServiceAApplicationTests.java │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ └── maven-wrapper.properties │ └── pom.xml ├── service-b │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── service_b │ │ │ │ └── ServiceBApplication.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── service_b │ │ │ └── ServiceBApplicationTests.java │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ └── maven-wrapper.properties │ └── pom.xml ├── service-registry │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── service_registry │ │ │ │ └── ServiceRegistryApplication.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── service_registry │ │ │ └── ServiceRegistryApplicationTests.java │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ └── maven-wrapper.properties │ └── pom.xml └── config-server │ ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── config_server │ │ │ └── ConfigServerApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── config_server │ │ └── ConfigServerApplicationTests.java │ ├── .gitignore │ ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties │ └── pom.xml ├── integration ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── integration │ │ │ └── IntegrationApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── integration │ │ └── IntegrationApplicationTests.java ├── compose.yaml ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties └── pom.xml ├── beans ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── beans.xml │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── beans │ │ │ └── BeansApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── beans │ │ └── BeansApplicationTests.java ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── pom.xml └── mvnw.cmd ├── web ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── graphql │ │ │ │ └── schema.graphqls │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── web │ │ │ ├── Order.java │ │ │ ├── OrderService.java │ │ │ ├── WebApplication.java │ │ │ ├── OrderRestController.java │ │ │ ├── OrderGraphqlController.java │ │ │ └── Clients.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── web │ │ └── WebApplicationTests.java ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── pom.xml └── mvnw.cmd ├── development-desk-check ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── development_desk_check │ │ │ └── DevelopmentDeskCheckApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── development_desk_check │ │ └── DevelopmentDeskCheckApplicationTests.java ├── .envrc ├── .sdkmanrc ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties └── pom.xml ├── data-oriented-programming ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── data_oriented_programming │ │ │ └── DataOrientedProgrammingApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── data_oriented_programming │ │ └── DataOrientedProgrammingApplicationTests.java ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties └── pom.xml ├── data ├── src │ ├── main │ │ ├── resources │ │ │ ├── db │ │ │ │ └── migration │ │ │ │ │ ├── V3__line_item_id.sql │ │ │ │ │ ├── V1__baseline.sql │ │ │ │ │ └── V2__data.sql │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── data │ │ │ └── DataApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── data │ │ └── DataApplicationTests.java ├── compose.yaml ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── pom.xml └── mvnw.cmd ├── modularity ├── src │ ├── main │ │ ├── resources │ │ │ ├── data.sql │ │ │ ├── schema.sql │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── modularity │ │ │ ├── adoptions │ │ │ ├── DogAdoptionEvent.java │ │ │ └── DogAdoptionController.java │ │ │ ├── ModularityApplication.java │ │ │ └── vet │ │ │ └── Dogtor.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── modularity │ │ └── ModularityApplicationTests.java ├── compose.yaml ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties └── pom.xml ├── batch ├── src │ ├── main │ │ ├── resources │ │ │ ├── input.csv │ │ │ ├── schema.sql │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── batch │ │ │ └── BatchApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── batch │ │ └── BatchApplicationTests.java ├── compose.yaml ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── pom.xml └── mvnw.cmd ├── basics ├── src │ ├── main │ │ ├── resources │ │ │ ├── data.sql │ │ │ ├── schema.sql │ │ │ ├── application.properties │ │ │ └── banner.txt │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── basics │ │ │ └── BasicsApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── basics │ │ ├── TestBasicsApplication.java │ │ ├── BasicsApplicationTests.java │ │ └── TestcontainersConfiguration.java ├── compose.yaml ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── pom.xml └── mvnw.cmd ├── scalability ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── scalability │ │ │ └── ScalabilityApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── scalability │ │ └── ScalabilityApplicationTests.java ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties └── pom.xml ├── security ├── resource-server │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── bootiful │ │ │ │ └── resource_server │ │ │ │ └── ResourceServerApplication.java │ │ └── test │ │ │ └── java │ │ │ └── bootiful │ │ │ └── resource_server │ │ │ └── ResourceServerApplicationTests.java │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ └── maven-wrapper.properties │ └── pom.xml ├── misc │ ├── init_db.sh │ └── legacy-schema.sql ├── passwordless │ ├── compose.yaml │ ├── src │ │ ├── test │ │ │ └── java │ │ │ │ └── bootiful │ │ │ │ └── passwordless │ │ │ │ └── PasswordlessApplicationTests.java │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── bootiful │ │ │ └── passwordless │ │ │ └── PasswordlessApplication.java │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ └── maven-wrapper.properties │ └── pom.xml └── oauth-login │ ├── src │ ├── test │ │ └── java │ │ │ └── bootiful │ │ │ └── oauth_login │ │ │ └── OauthLoginApplicationTests.java │ └── main │ │ ├── resources │ │ └── application.yml │ │ └── java │ │ └── bootiful │ │ └── oauth_login │ │ └── OauthLoginApplication.java │ ├── .gitignore │ ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties │ └── pom.xml └── README.md /ai/README.md: -------------------------------------------------------------------------------- 1 | # README -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .idea 3 | -------------------------------------------------------------------------------- /aot/src/main/resources/message: -------------------------------------------------------------------------------- 1 | hello, world! -------------------------------------------------------------------------------- /microservices/config/service-a.properties: -------------------------------------------------------------------------------- 1 | server.port=8081 2 | -------------------------------------------------------------------------------- /microservices/config/service-b.properties: -------------------------------------------------------------------------------- 1 | server.port=8082 2 | -------------------------------------------------------------------------------- /aot/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=aot 2 | -------------------------------------------------------------------------------- /integration/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=integration 2 | -------------------------------------------------------------------------------- /beans/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=beans 2 | bootiful.name=Bob -------------------------------------------------------------------------------- /microservices/config/application.properties: -------------------------------------------------------------------------------- 1 | message=hello, spring cloud config server (application) -------------------------------------------------------------------------------- /aot/native.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ./mvnw -DskipTests -Pnative native:compile 4 | ./target/aot -------------------------------------------------------------------------------- /web/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=web 2 | spring.graphql.graphiql.enabled=true -------------------------------------------------------------------------------- /development-desk-check/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=development-desk-check 2 | -------------------------------------------------------------------------------- /data-oriented-programming/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=data-oriented-programming 2 | -------------------------------------------------------------------------------- /data/src/main/resources/db/migration/V3__line_item_id.sql: -------------------------------------------------------------------------------- 1 | alter table line_item add column id serial primary key not null ; -------------------------------------------------------------------------------- /development-desk-check/.envrc: -------------------------------------------------------------------------------- 1 | #export KEY=123 2 | export KEY=$( bw get item bootiful-workshop-demo-key | jq -r '.notes' ) 3 | -------------------------------------------------------------------------------- /microservices/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joshlong-attic/2024-bootiful-spring-workshop/HEAD/microservices/.DS_Store -------------------------------------------------------------------------------- /modularity/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | delete from dog; 2 | insert into dog (id , name, owner) values ( 45, 'Prancer', null); -------------------------------------------------------------------------------- /batch/src/main/resources/input.csv: -------------------------------------------------------------------------------- 1 | id,name 2 | 1,madhura 3 | 2,juergen 4 | 3,olga 5 | 4,dave 6 | 5,violetta 7 | 6,stephane 8 | 7,josh -------------------------------------------------------------------------------- /microservices/service-a/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=service-a 2 | spring.config.import=configserver: -------------------------------------------------------------------------------- /microservices/config/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joshlong-attic/2024-bootiful-spring-workshop/HEAD/microservices/config/.DS_Store -------------------------------------------------------------------------------- /microservices/service-b/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=service-b 2 | spring.config.import=configserver: 3 | -------------------------------------------------------------------------------- /basics/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | delete from customer; 2 | insert into customer(name) values ('Madhura'); 3 | insert into customer(name) values ('Juergen'); -------------------------------------------------------------------------------- /basics/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | create table if not exists customer 2 | ( 3 | id serial primary key, 4 | name text not null 5 | ); 6 | 7 | -------------------------------------------------------------------------------- /development-desk-check/.sdkmanrc: -------------------------------------------------------------------------------- 1 | # Enable auto-env through the sdkman_auto_env config 2 | # Add key=value pairs of SDKs to use below 3 | java=23-graalce 4 | -------------------------------------------------------------------------------- /basics/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=basics 2 | spring.docker.compose.lifecycle-management=start_only 3 | spring.sql.init.mode=always -------------------------------------------------------------------------------- /scalability/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=scalability 2 | 3 | server.tomcat.threads.max=10 4 | spring.threads.virtual.enabled=true -------------------------------------------------------------------------------- /batch/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | create table if not exists customer 2 | ( 3 | id serial primary key, 4 | name text not null 5 | ) ; 6 | delete from customer; -------------------------------------------------------------------------------- /modularity/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | create table if not exists dog 2 | ( 3 | id serial primary key, 4 | name text not null, 5 | owner text null 6 | ); -------------------------------------------------------------------------------- /web/src/main/java/com/example/web/Order.java: -------------------------------------------------------------------------------- 1 | package com.example.web; 2 | 3 | record Order(int id, String sku, float price) { 4 | } 5 | 6 | record LineItem(int id) { 7 | } -------------------------------------------------------------------------------- /security/resource-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=resource-server 2 | server.port=9091 3 | spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:8080 -------------------------------------------------------------------------------- /data/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=data 2 | spring.datasource.password=secret 3 | spring.datasource.username=myuser 4 | spring.datasource.url=jdbc:postgresql://localhost/mydatabase -------------------------------------------------------------------------------- /microservices/service-registry/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=service-registry 2 | server.port=8761 3 | eureka.client.register-with-eureka=false 4 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /integration/compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | rabbitmq: 3 | image: 'rabbitmq:latest' 4 | environment: 5 | - 'RABBITMQ_DEFAULT_PASS=secret' 6 | - 'RABBITMQ_DEFAULT_USER=myuser' 7 | ports: 8 | - '5672:5672' 9 | -------------------------------------------------------------------------------- /basics/compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | postgres: 3 | image: 'postgres:latest' 4 | environment: 5 | - 'POSTGRES_DB=mydatabase' 6 | - 'POSTGRES_PASSWORD=secret' 7 | - 'POSTGRES_USER=myuser' 8 | ports: 9 | - '5432:5432' 10 | -------------------------------------------------------------------------------- /batch/compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | postgres: 3 | image: 'postgres:latest' 4 | environment: 5 | - 'POSTGRES_DB=mydatabase' 6 | - 'POSTGRES_PASSWORD=secret' 7 | - 'POSTGRES_USER=myuser' 8 | ports: 9 | - '5432:5432' 10 | -------------------------------------------------------------------------------- /data/compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | postgres: 3 | image: 'postgres:latest' 4 | environment: 5 | - 'POSTGRES_DB=mydatabase' 6 | - 'POSTGRES_PASSWORD=secret' 7 | - 'POSTGRES_USER=myuser' 8 | ports: 9 | - '5432:5432' 10 | -------------------------------------------------------------------------------- /security/misc/init_db.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | cat `dirname $0`/legacy-schema.sql | PGPASSWORD=secret psql -U myuser -h localhost mydatabase 3 | 4 | # if you want to use the SQL then remember to run: 5 | # update users set password = '{sha256}' || password ; -------------------------------------------------------------------------------- /modularity/compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | postgres: 3 | image: 'postgres:latest' 4 | environment: 5 | - 'POSTGRES_DB=mydatabase' 6 | - 'POSTGRES_PASSWORD=secret' 7 | - 'POSTGRES_USER=myuser' 8 | ports: 9 | - '5432:5432' 10 | -------------------------------------------------------------------------------- /modularity/src/main/java/com/example/modularity/adoptions/DogAdoptionEvent.java: -------------------------------------------------------------------------------- 1 | package com.example.modularity.adoptions; 2 | 3 | import org.springframework.modulith.events.Externalized; 4 | 5 | @Externalized 6 | public record DogAdoptionEvent (int dogId) { 7 | } 8 | -------------------------------------------------------------------------------- /security/passwordless/compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | postgres: 3 | image: 'postgres:latest' 4 | environment: 5 | - 'POSTGRES_DB=mydatabase' 6 | - 'POSTGRES_PASSWORD=secret' 7 | - 'POSTGRES_USER=myuser' 8 | ports: 9 | - '5432:5432' 10 | -------------------------------------------------------------------------------- /microservices/config-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=config-server 2 | # 3 | server.port=8888 4 | spring.cloud.config.server.git.uri=https://github.com/joshlong-attic/2024-bootiful-spring-workshop.git 5 | spring.cloud.config.server.git.search-paths=microservices/config -------------------------------------------------------------------------------- /ai/src/test/java/com/example/ai/AiApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.ai; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class AiApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /data/src/main/resources/db/migration/V1__baseline.sql: -------------------------------------------------------------------------------- 1 | create table if not exists customer 2 | ( 3 | id serial primary key not null , 4 | name text not null 5 | ); 6 | 7 | create table if not exists line_item 8 | ( 9 | customer bigint references customer (id), 10 | sku text not null 11 | ); -------------------------------------------------------------------------------- /aot/src/test/java/com/example/aot/AotApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.aot; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class AotApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /web/src/test/java/com/example/web/WebApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.web; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class WebApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /data/src/test/java/com/example/data/DataApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.data; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class DataApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /batch/src/test/java/com/example/batch/BatchApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.batch; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class BatchApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /beans/src/test/java/com/example/beans/BeansApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.beans; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class BeansApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /ai/compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | pgvector: 3 | image: 'pgvector/pgvector:pg16' 4 | environment: 5 | - 'POSTGRES_DB=mydatabase' 6 | - 'POSTGRES_PASSWORD=secret' 7 | - 'POSTGRES_USER=myuser' 8 | labels: 9 | - "org.springframework.boot.service-connection=postgres" 10 | ports: 11 | - '5432:5432' -------------------------------------------------------------------------------- /batch/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=batch 2 | # 3 | spring.datasource.url=jdbc:postgresql://localhost/mydatabase 4 | spring.datasource.username=myuser 5 | spring.datasource.password=secret 6 | # 7 | init-schema=always 8 | spring.batch.jdbc.initialize-schema=${init-schema} 9 | spring.sql.init.mode=${init-schema} -------------------------------------------------------------------------------- /modularity/src/test/java/com/example/modularity/ModularityApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.modularity; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ModularityApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /integration/src/test/java/com/example/integration/IntegrationApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.integration; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class IntegrationApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /scalability/src/test/java/com/example/scalability/ScalabilityApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.scalability; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ScalabilityApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /microservices/service-a/src/test/java/com/example/service_a/ServiceAApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.service_a; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ServiceAApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /microservices/service-b/src/test/java/com/example/service_b/ServiceBApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.service_b; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ServiceBApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /security/oauth-login/src/test/java/bootiful/oauth_login/OauthLoginApplicationTests.java: -------------------------------------------------------------------------------- 1 | package bootiful.oauth_login; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class OauthLoginApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /security/passwordless/src/test/java/bootiful/passwordless/PasswordlessApplicationTests.java: -------------------------------------------------------------------------------- 1 | package bootiful.passwordless; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class PasswordlessApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /basics/src/test/java/com/example/basics/TestBasicsApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.basics; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | 5 | public class TestBasicsApplication { 6 | 7 | public static void main(String[] args) { 8 | SpringApplication.from(BasicsApplication::main).with(TestcontainersConfiguration.class).run(args); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /microservices/config-server/src/test/java/com/example/config_server/ConfigServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.config_server; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ConfigServerApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /security/resource-server/src/test/java/bootiful/resource_server/ResourceServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package bootiful.resource_server; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ResourceServerApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /ai/src/main/resources/my-system-prompt.md: -------------------------------------------------------------------------------- 1 | You are an AI powered assistant to help people adopt a dog 2 | from the adoption agency named Pooch Palace with locations in 3 | Seoul, Tokyo, Singapore, Paris, Mumbai, New Delhi, San Francisco, 4 | and London. If you don't know about the dogs housed at our particular 5 | stores, then return a disappointed response suggesting we don't 6 | have any dogs available. -------------------------------------------------------------------------------- /microservices/service-registry/src/test/java/com/example/service_registry/ServiceRegistryApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.service_registry; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ServiceRegistryApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /development-desk-check/src/test/java/com/example/development_desk_check/DevelopmentDeskCheckApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.development_desk_check; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class DevelopmentDeskCheckApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /modularity/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=modularity 2 | # 3 | spring.modulith.republish-outstanding-events-on-restart=true 4 | spring.modulith.events.jdbc.schema-initialization.enabled=true 5 | # 6 | spring.datasource.password=secret 7 | spring.datasource.username=myuser 8 | spring.datasource.url=jdbc:postgresql://localhost/mydatabase 9 | # 10 | spring.sql.init.mode=always -------------------------------------------------------------------------------- /ai/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=ai 2 | #export SPRING_AI_OPENAI_IMAGE_API_KEY=... 3 | spring.ai.openai.chat.options.model=gpt-4o 4 | #spring.ai.vectorstore.pgvector.initialize-schema=true 5 | # 6 | spring.datasource.url=jdbc:postgresql://localhost/mydatabase 7 | spring.datasource.username=myuser 8 | spring.datasource.password=secret 9 | # 10 | spring.sql.init.mode=always 11 | # 12 | -------------------------------------------------------------------------------- /data-oriented-programming/src/test/java/com/example/data_oriented_programming/DataOrientedProgrammingApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.data_oriented_programming; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class DataOrientedProgrammingApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /web/src/main/resources/graphql/schema.graphqls: -------------------------------------------------------------------------------- 1 | type Mutation { 2 | create(id:Int, sku:String , price:Float):Order 3 | } 4 | 5 | type Order { 6 | id : Int 7 | date : String 8 | sku : String 9 | price : Float 10 | lineItems: [LineItem] 11 | } 12 | 13 | type LineItem { 14 | id: Int 15 | } 16 | 17 | type Query { 18 | 19 | all : [Order] 20 | 21 | id (id:Int): Order 22 | 23 | 24 | } -------------------------------------------------------------------------------- /basics/src/test/java/com/example/basics/BasicsApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.basics; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | import org.springframework.context.annotation.Import; 6 | 7 | @Import(TestcontainersConfiguration.class) 8 | @SpringBootTest 9 | class BasicsApplicationTests { 10 | 11 | @Test 12 | void contextLoads() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /security/oauth-login/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9090 3 | spring: 4 | security: 5 | oauth2: 6 | client: 7 | registration: 8 | spring: 9 | client-secret: spring 10 | client-id: spring 11 | scope: 12 | - openid 13 | - profile 14 | provider: 15 | spring: 16 | issuer-uri: http://localhost:8080 -------------------------------------------------------------------------------- /modularity/src/main/java/com/example/modularity/ModularityApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.modularity; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ModularityApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ModularityApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /ai/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE if not exists dog 2 | ( 3 | id serial primary key , 4 | name text NOT NULL, 5 | description text NOT NULL, 6 | dob date NOT NULL, 7 | owner text, 8 | gender character(1) DEFAULT 'f'::bpchar NOT NULL, 9 | image text NOT NULL 10 | ); 11 | 12 | 13 | -------------------------------------------------------------------------------- /data/src/main/resources/db/migration/V2__data.sql: -------------------------------------------------------------------------------- 1 | insert into customer(name) values ('Josh'); 2 | insert into customer(name) values ('Juergen'); 3 | 4 | insert into line_item( customer, sku) 5 | values ( ( select id from customer where name ='Josh') ,'123' ); 6 | 7 | insert into line_item( customer, sku) 8 | values ( ( select id from customer where name ='Josh') ,'456' ); 9 | 10 | insert into line_item( customer, sku) 11 | values ( ( select id from customer where name ='Juergen') ,'123' ); -------------------------------------------------------------------------------- /beans/src/main/resources/beans.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /modularity/src/main/java/com/example/modularity/vet/Dogtor.java: -------------------------------------------------------------------------------- 1 | package com.example.modularity.vet; 2 | 3 | import com.example.modularity.adoptions.DogAdoptionEvent; 4 | import org.springframework.context.event.EventListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | class Dogtor { 9 | 10 | @EventListener 11 | void dogAdoptedEvent (DogAdoptionEvent dogAdoptionEvent) { 12 | System.out.println("checking up on the health of the dog [" + 13 | dogAdoptionEvent +"]"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ai/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /aot/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /basics/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /batch/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /beans/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /data/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /web/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /integration/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /modularity/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /scalability/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /microservices/config-server/src/main/java/com/example/config_server/ConfigServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.config_server; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.config.server.EnableConfigServer; 6 | 7 | @EnableConfigServer 8 | @SpringBootApplication 9 | public class ConfigServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConfigServerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /security/oauth-login/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /security/passwordless/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /data-oriented-programming/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /development-desk-check/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /microservices/service-a/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /microservices/service-b/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /security/resource-server/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /microservices/config-server/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /microservices/service-registry/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /microservices/service-registry/src/main/java/com/example/service_registry/ServiceRegistryApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.service_registry; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @EnableEurekaServer 8 | @SpringBootApplication 9 | public class ServiceRegistryApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ServiceRegistryApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /basics/src/test/java/com/example/basics/TestcontainersConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.example.basics; 2 | 3 | import org.springframework.boot.test.context.TestConfiguration; 4 | import org.springframework.boot.testcontainers.service.connection.ServiceConnection; 5 | import org.springframework.context.annotation.Bean; 6 | import org.testcontainers.containers.PostgreSQLContainer; 7 | import org.testcontainers.utility.DockerImageName; 8 | 9 | @TestConfiguration(proxyBeanMethods = false) 10 | class TestcontainersConfiguration { 11 | 12 | @Bean 13 | @ServiceConnection 14 | PostgreSQLContainer postgresContainer() { 15 | return new PostgreSQLContainer<>(DockerImageName.parse("postgres:latest")); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /security/passwordless/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | security: 3 | oauth2: 4 | authorizationserver: 5 | client: 6 | oidc-client: 7 | registration: 8 | client-id: "spring" 9 | client-secret: "{noop}spring" 10 | client-authentication-methods: 11 | - "client_secret_basic" 12 | authorization-grant-types: 13 | - "authorization_code" 14 | - "refresh_token" 15 | redirect-uris: 16 | - "http://127.0.0.1:9090/login/oauth2/code/spring" 17 | scopes: 18 | - "openid" 19 | - "profile" 20 | application: 21 | name: passwordless 22 | datasource: 23 | url: jdbc:postgresql://localhost/mydatabase 24 | username: myuser 25 | password: secret -------------------------------------------------------------------------------- /development-desk-check/src/main/java/com/example/development_desk_check/DevelopmentDeskCheckApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.development_desk_check; 2 | 3 | import org.springframework.boot.ApplicationRunner; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.core.env.Environment; 8 | 9 | @SpringBootApplication 10 | public class DevelopmentDeskCheckApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(DevelopmentDeskCheckApplication.class, args); 14 | } 15 | 16 | @Bean 17 | ApplicationRunner demo(Environment environment) { 18 | return _ -> System.out.println("you've been Juergenized, " + environment.getProperty("user.name") 19 | + ", and your key is " + environment.getProperty("key") + "!"); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /security/resource-server/src/main/java/bootiful/resource_server/ResourceServerApplication.java: -------------------------------------------------------------------------------- 1 | package bootiful.resource_server; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | import java.security.Principal; 10 | import java.util.Map; 11 | 12 | @SpringBootApplication 13 | public class ResourceServerApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(ResourceServerApplication.class, args); 17 | } 18 | 19 | } 20 | 21 | @Controller 22 | @ResponseBody 23 | class ClientController { 24 | 25 | @GetMapping("/") 26 | Map hello(Principal principal) { 27 | return Map.of("message", "hello from the resource server, " + principal.getName()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /web/src/main/java/com/example/web/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.example.web; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | import java.util.Collection; 6 | import java.util.Map; 7 | import java.util.UUID; 8 | import java.util.concurrent.ConcurrentHashMap; 9 | 10 | @Service 11 | class OrderService { 12 | 13 | private final Map orders = new ConcurrentHashMap<>(); 14 | 15 | OrderService() { 16 | this.orders.putAll(Map.of(1, newOrder(1), 2, newOrder(2))); 17 | } 18 | 19 | Collection getAll() { 20 | return this.orders.values(); 21 | } 22 | 23 | Order getById(int id) { 24 | return this.orders.get(id); 25 | } 26 | 27 | Order create(Order order) { 28 | this.orders.put(order.id(), order); 29 | return order; 30 | } 31 | 32 | private static Order newOrder(int id) { 33 | return new Order(id, UUID.randomUUID().toString(), 34 | (float) (Math.random() * 100)); 35 | } 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /ai/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /aot/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /data-oriented-programming/src/main/java/com/example/data_oriented_programming/DataOrientedProgrammingApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.data_oriented_programming; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DataOrientedProgrammingApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DataOrientedProgrammingApplication.class, args); 11 | } 12 | 13 | } 14 | 15 | class Loans { 16 | 17 | String displayMessageFor(Loan loan) { 18 | return switch (loan) { 19 | case UnsecuredLoan(var interest) -> "ouch! that " + interest + "% rate is going to hurt!"; 20 | case SecuredLoan sl -> "good job! nice loan."; 21 | }; 22 | } 23 | } 24 | 25 | sealed interface Loan permits SecuredLoan, UnsecuredLoan { 26 | } 27 | 28 | final class SecuredLoan implements Loan { 29 | } 30 | 31 | record UnsecuredLoan(float interest) implements Loan { 32 | } -------------------------------------------------------------------------------- /web/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /basics/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /batch/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /beans/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /data/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /integration/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /modularity/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /scalability/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /development-desk-check/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /microservices/service-a/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /microservices/service-b/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /security/oauth-login/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip 20 | -------------------------------------------------------------------------------- /security/passwordless/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip 20 | -------------------------------------------------------------------------------- /data-oriented-programming/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /microservices/config-server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /security/resource-server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip 20 | -------------------------------------------------------------------------------- /microservices/service-registry/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /microservices/service-b/src/main/java/com/example/service_b/ServiceBApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.service_b; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | 10 | import java.util.Map; 11 | 12 | @SpringBootApplication 13 | public class ServiceBApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(ServiceBApplication.class, args); 17 | } 18 | 19 | } 20 | 21 | @Controller 22 | @ResponseBody 23 | class ProducerController { 24 | 25 | private final String value; 26 | 27 | ProducerController(@Value("${message}") String value) { 28 | this.value = value; 29 | } 30 | 31 | @GetMapping("/answer") 32 | Map answer() { 33 | return Map.of("message", this.value); 34 | } 35 | } -------------------------------------------------------------------------------- /web/src/main/java/com/example/web/WebApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.web; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.servlet.function.HandlerFunction; 7 | import org.springframework.web.servlet.function.RouterFunction; 8 | import org.springframework.web.servlet.function.ServerRequest; 9 | import org.springframework.web.servlet.function.ServerResponse; 10 | 11 | import java.util.Map; 12 | 13 | import static org.springframework.web.servlet.function.RouterFunctions.route; 14 | 15 | @SpringBootApplication 16 | public class WebApplication { 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(WebApplication.class, args); 20 | } 21 | 22 | @Bean 23 | RouterFunction httpRequest() { 24 | return route() 25 | .GET("/hello", _ -> ServerResponse.ok().body(Map.of("message", "Hello World"))) 26 | .build(); 27 | } 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /data/src/main/java/com/example/data/DataApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.data; 2 | 3 | import org.springframework.boot.ApplicationRunner; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.data.annotation.Id; 8 | import org.springframework.data.repository.CrudRepository; 9 | 10 | import java.util.Collection; 11 | import java.util.Set; 12 | 13 | @SpringBootApplication 14 | public class DataApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(DataApplication.class, args); 18 | } 19 | 20 | @Bean 21 | ApplicationRunner runner(CustomerRepository repository) { 22 | return _ -> repository.findAll().forEach(System.out::println); 23 | } 24 | } 25 | 26 | interface CustomerRepository extends CrudRepository { 27 | } 28 | 29 | record LineItem(@Id int id, String sku , int customer) { 30 | } 31 | 32 | record Customer(@Id int id, String name, Set lineItems) { 33 | } -------------------------------------------------------------------------------- /web/src/main/java/com/example/web/OrderRestController.java: -------------------------------------------------------------------------------- 1 | package com.example.web; 2 | 3 | import org.springframework.graphql.data.method.annotation.BatchMapping; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.*; 7 | 8 | import java.util.Collection; 9 | 10 | @Controller 11 | @ResponseBody 12 | @RequestMapping("/orders") 13 | class OrderRestController { 14 | 15 | 16 | private final OrderService service; 17 | 18 | OrderRestController(OrderService service) { 19 | this.service = service; 20 | } 21 | 22 | // curl http://localhost:8080/orders 23 | @GetMapping 24 | Collection getAll() { 25 | return this.service.getAll(); 26 | } 27 | 28 | // curl http://localhost:8080/orders/1 29 | @GetMapping("/{id}") 30 | Order getById(@PathVariable int id) { 31 | return this.service.getById(id); 32 | } 33 | 34 | // curl -XPOST -H"content-type: application/json" -d'{"sku":"12345" , "id":3, "price": 2322.0}' http://localhost:8080/orders 35 | @PostMapping 36 | ResponseEntity create(@RequestBody Order order) { 37 | this.service.create(order); 38 | return ResponseEntity.ok().build(); 39 | } 40 | 41 | 42 | 43 | } 44 | 45 | -------------------------------------------------------------------------------- /basics/src/main/java/com/example/basics/BasicsApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.basics; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.jdbc.core.simple.JdbcClient; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | 10 | import java.util.Collection; 11 | 12 | @SpringBootApplication 13 | public class BasicsApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(BasicsApplication.class, args); 17 | } 18 | 19 | } 20 | 21 | @Controller 22 | @ResponseBody 23 | class CustomerController { 24 | 25 | private final JdbcClient db; 26 | 27 | CustomerController(JdbcClient db) { 28 | this.db = db; 29 | } 30 | 31 | @GetMapping ("/hello") 32 | String hello (){ 33 | // refactor and rebuild 34 | return "Hello World!" ; 35 | } 36 | 37 | @GetMapping("/customers") 38 | Collection customers() { 39 | return this.db 40 | .sql("select * from customer") 41 | .query((rs, _) -> new Customer(rs.getInt("id"), 42 | rs.getString("name"))) 43 | .list(); 44 | } 45 | } 46 | 47 | record Customer(int id, String name) { 48 | } 49 | -------------------------------------------------------------------------------- /integration/src/main/java/com/example/integration/IntegrationApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.integration; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.integration.core.GenericHandler; 8 | import org.springframework.integration.dsl.IntegrationFlow; 9 | import org.springframework.integration.file.dsl.Files; 10 | 11 | import java.io.File; 12 | 13 | @SpringBootApplication 14 | public class IntegrationApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(IntegrationApplication.class, args); 18 | } 19 | 20 | @Bean 21 | IntegrationFlow newFilesIntegrationFlow(@Value("file://${HOME}/Desktop/inbound") File in, 22 | @Value("file://${HOME}/Desktop/outbound") File out) { 23 | return IntegrationFlow 24 | .from(Files.inboundAdapter(in).autoCreateDirectory(true)) 25 | .handle((GenericHandler) (payload, _) -> { 26 | System.out.println("got a new file called " + payload.getAbsolutePath() + '.'); 27 | return payload; 28 | }) 29 | .handle(Files.outboundAdapter(out).autoCreateDirectory(true)) 30 | .get(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /data-oriented-programming/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | data-oriented-programming 13 | 0.0.1-SNAPSHOT 14 | data-oriented-programming 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-maven-plugin 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /security/oauth-login/src/main/java/bootiful/oauth_login/OauthLoginApplication.java: -------------------------------------------------------------------------------- 1 | package bootiful.oauth_login; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.core.ParameterizedTypeReference; 6 | import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; 7 | import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.ResponseBody; 11 | import org.springframework.web.client.RestClient; 12 | 13 | import java.util.Map; 14 | 15 | @SpringBootApplication 16 | public class OauthLoginApplication { 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(OauthLoginApplication.class, args); 20 | } 21 | 22 | } 23 | 24 | @Controller 25 | @ResponseBody 26 | class ClientController { 27 | 28 | private final RestClient http; 29 | 30 | ClientController(RestClient.Builder http) { 31 | this.http = http.build(); 32 | } 33 | 34 | @GetMapping("/") 35 | Map hello(@RegisteredOAuth2AuthorizedClient OAuth2AuthorizedClient oAuth2AuthorizedClient) { 36 | var token = oAuth2AuthorizedClient.getAccessToken(); 37 | return http 38 | .get() 39 | .uri("http://localhost:9091/") 40 | .headers(httpHeaders -> httpHeaders.setBearerAuth(token.getTokenValue())) 41 | .retrieve() 42 | .body(new ParameterizedTypeReference<>() { 43 | }); 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /aot/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | aot 13 | 0.0.1-SNAPSHOT 14 | aot 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.graalvm.buildtools 49 | native-maven-plugin 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-maven-plugin 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /scalability/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | scalability 13 | 0.0.1-SNAPSHOT 14 | scalability 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.graalvm.buildtools 49 | native-maven-plugin 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-maven-plugin 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /beans/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | beans 13 | 0.0.1-SNAPSHOT 14 | beans 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-configuration-processor 46 | annotationProcessor 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-maven-plugin 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /security/resource-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.3 9 | 10 | 11 | bootiful 12 | resource-server 13 | 0.0.1-SNAPSHOT 14 | resource-server 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 21 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-oauth2-resource-server 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-web 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.graalvm.buildtools 53 | native-maven-plugin 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-maven-plugin 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /modularity/src/main/java/com/example/modularity/adoptions/DogAdoptionController.java: -------------------------------------------------------------------------------- 1 | package com.example.modularity.adoptions; 2 | 3 | import org.springframework.context.ApplicationEventPublisher; 4 | import org.springframework.data.annotation.Id; 5 | import org.springframework.data.repository.ListCrudRepository; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | 12 | import java.util.Map; 13 | 14 | @Controller 15 | class DogAdoptionController { 16 | 17 | private final DogAdoptionService service; 18 | 19 | DogAdoptionController(DogAdoptionService service) { 20 | this.service = service; 21 | } 22 | 23 | @PostMapping("/dogs/{dogId}/adoptions") 24 | void adopt(@PathVariable int dogId, Map owner) { 25 | this.service.adopt(dogId, owner.get("name")); 26 | } 27 | } 28 | 29 | 30 | @Service 31 | @Transactional 32 | class DogAdoptionService { 33 | 34 | private final DogRepository repository; 35 | private final ApplicationEventPublisher publisher; 36 | 37 | DogAdoptionService(DogRepository repository, ApplicationEventPublisher publisher) { 38 | this.repository = repository; 39 | this.publisher = publisher; 40 | } 41 | 42 | void adopt(int dogId, String ownerName) { 43 | this.repository.findById(dogId).ifPresent(dog -> { 44 | var newDog = this.repository.save(new Dog(dog.id(), 45 | ownerName, dog.name())); 46 | System.out.println("adopted [" + newDog + "]"); 47 | this.publisher.publishEvent(new DogAdoptionEvent(dog.id())); 48 | }); 49 | } 50 | } 51 | 52 | interface DogRepository extends ListCrudRepository { 53 | } 54 | 55 | record Dog(@Id int id, String owner, String name) { 56 | } -------------------------------------------------------------------------------- /microservices/service-a/src/main/java/com/example/service_a/ServiceAApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.service_a; 2 | 3 | import org.springframework.boot.ApplicationRunner; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.core.ParameterizedTypeReference; 9 | import org.springframework.core.env.Environment; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.web.bind.annotation.GetMapping; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | import org.springframework.web.client.RestClient; 14 | 15 | import java.util.Map; 16 | 17 | 18 | @SpringBootApplication 19 | public class ServiceAApplication { 20 | 21 | public static void main(String[] args) { 22 | SpringApplication.run(ServiceAApplication.class, args); 23 | } 24 | 25 | @Bean 26 | ApplicationRunner configClientRunner(Environment environment) { 27 | return _ -> System.out.println("message: [" + environment.getProperty("message") + "]"); 28 | } 29 | 30 | @Bean 31 | @LoadBalanced 32 | RestClient.Builder restClientBuilder() { 33 | return RestClient.builder(); 34 | } 35 | 36 | @Bean 37 | RestClient restClient(RestClient.Builder builder) { 38 | return builder.build(); 39 | } 40 | } 41 | 42 | @Controller 43 | @ResponseBody 44 | class ConsumerController { 45 | 46 | private final RestClient http; 47 | 48 | ConsumerController(RestClient http) { 49 | this.http = http; 50 | } 51 | 52 | @GetMapping("/call") 53 | Map call() { 54 | return this.http 55 | .get() 56 | .uri("http://service-b/answer") 57 | .retrieve() 58 | .body(new ParameterizedTypeReference>() {}); 59 | } 60 | } -------------------------------------------------------------------------------- /batch/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | batch 13 | 0.0.1-SNAPSHOT 14 | batch 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-batch 36 | 37 | 38 | org.postgresql 39 | postgresql 40 | runtime 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | org.springframework.batch 49 | spring-batch-test 50 | test 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.graalvm.buildtools 58 | native-maven-plugin 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-maven-plugin 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /microservices/config-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | config-server 13 | 0.0.1-SNAPSHOT 14 | config-server 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 2023.0.3 32 | 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-config-server 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-test 42 | test 43 | 44 | 45 | 46 | 47 | 48 | org.springframework.cloud 49 | spring-cloud-dependencies 50 | ${spring-cloud.version} 51 | pom 52 | import 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-maven-plugin 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /microservices/service-registry/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | service-registry 13 | 0.0.1-SNAPSHOT 14 | service-registry 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 2023.0.3 32 | 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-netflix-eureka-server 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-test 42 | test 43 | 44 | 45 | 46 | 47 | 48 | org.springframework.cloud 49 | spring-cloud-dependencies 50 | ${spring-cloud.version} 51 | pom 52 | import 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-maven-plugin 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /security/oauth-login/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.3 9 | 10 | 11 | bootiful 12 | oauth-login 13 | 0.0.1-SNAPSHOT 14 | oauth-login 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 21 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-oauth2-client 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-web 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | org.springframework.security 49 | spring-security-test 50 | test 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.graalvm.buildtools 58 | native-maven-plugin 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-maven-plugin 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /web/src/main/java/com/example/web/OrderGraphqlController.java: -------------------------------------------------------------------------------- 1 | package com.example.web; 2 | 3 | import org.springframework.graphql.data.method.annotation.*; 4 | import org.springframework.stereotype.Controller; 5 | 6 | import java.text.SimpleDateFormat; 7 | import java.util.*; 8 | 9 | /* 10 | some possible queries: 11 | ``` 12 | query { 13 | id(id: 2) { 14 | id 15 | date 16 | sku 17 | } 18 | 19 | all { 20 | id 21 | date 22 | sku 23 | } 24 | } 25 | ``` 26 | 27 | some possible mutations: 28 | 29 | ``` 30 | 31 | mutation { 32 | create (id:3,sku: "2322", price:22.0) { 33 | id, date ,sku 34 | } 35 | } 36 | 37 | ``` 38 | 39 | */ 40 | 41 | @Controller 42 | class OrderGraphqlController { 43 | 44 | private final OrderService service; 45 | 46 | OrderGraphqlController(OrderService service) { 47 | this.service = service; 48 | } 49 | 50 | @MutationMapping 51 | Order create(@Argument int id, 52 | @Argument String sku, 53 | @Argument float price) { 54 | return this.service.create( 55 | new Order(id, sku, price)); 56 | } 57 | 58 | @QueryMapping 59 | Collection all() { 60 | return this.service.getAll(); 61 | } 62 | 63 | @QueryMapping 64 | Order id(@Argument int id) { 65 | return this.service.getById(id); 66 | } 67 | 68 | @SchemaMapping 69 | String date(Order order) { 70 | // get the attribute by consulting some field in the database 71 | // for the order or something.. 72 | return SimpleDateFormat.getDateInstance().format(new Date()); 73 | } 74 | 75 | @BatchMapping 76 | Map> lineItems(List orderList) { 77 | // some query to get all LineItems mapping to these Orders 78 | System.out.println("batching all the lineItem lookups"); 79 | var ctr = 0; 80 | var map = new HashMap>(); 81 | for (var o : orderList) 82 | map.put(o, List.of(new LineItem(ctr++), new LineItem(ctr++))); 83 | return map; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /data/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | data 13 | 0.0.1-SNAPSHOT 14 | data 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-data-jdbc 36 | 37 | 38 | org.flywaydb 39 | flyway-core 40 | 41 | 42 | org.flywaydb 43 | flyway-database-postgresql 44 | 45 | 46 | 47 | org.postgresql 48 | postgresql 49 | runtime 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter-test 54 | test 55 | 56 | 57 | 58 | 59 | 60 | 61 | org.graalvm.buildtools 62 | native-maven-plugin 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-maven-plugin 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | web 13 | 0.0.1-SNAPSHOT 14 | web 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-graphql 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-web 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | org.springframework 49 | spring-webflux 50 | test 51 | 52 | 53 | org.springframework.graphql 54 | spring-graphql-test 55 | test 56 | 57 | 58 | 59 | 60 | 61 | 62 | org.graalvm.buildtools 63 | native-maven-plugin 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-maven-plugin 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /microservices/service-a/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | service-a 13 | 0.0.1-SNAPSHOT 14 | service-a 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 2023.0.3 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-starter-config 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-starter-netflix-eureka-client 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-test 50 | test 51 | 52 | 53 | 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-dependencies 58 | ${spring-cloud.version} 59 | pom 60 | import 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | org.graalvm.buildtools 69 | native-maven-plugin 70 | 71 | 72 | org.springframework.boot 73 | spring-boot-maven-plugin 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /microservices/service-b/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | service-b 13 | 0.0.1-SNAPSHOT 14 | service-b 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 2023.0.3 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-starter-config 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-starter-netflix-eureka-client 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-test 50 | test 51 | 52 | 53 | 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-dependencies 58 | ${spring-cloud.version} 59 | pom 60 | import 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | org.graalvm.buildtools 69 | native-maven-plugin 70 | 71 | 72 | org.springframework.boot 73 | spring-boot-maven-plugin 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /development-desk-check/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | development-desk-check 13 | 0.0.1-SNAPSHOT 14 | development-desk-check 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | 46 | 47 | 48 | io.spring.javaformat 49 | spring-javaformat-maven-plugin 50 | 0.0.43 51 | 52 | 53 | validate 54 | true 55 | 56 | validate 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /ai/src/main/java/com/example/ai/AiApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.ai; 2 | 3 | import org.springframework.ai.chat.client.ChatClient; 4 | import org.springframework.ai.chat.client.advisor.QuestionAnswerAdvisor; 5 | import org.springframework.ai.document.Document; 6 | import org.springframework.ai.vectorstore.VectorStore; 7 | import org.springframework.aot.hint.annotation.RegisterReflectionForBinding; 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.boot.ApplicationRunner; 10 | import org.springframework.boot.SpringApplication; 11 | import org.springframework.boot.autoconfigure.SpringBootApplication; 12 | import org.springframework.context.annotation.Bean; 13 | import org.springframework.core.io.Resource; 14 | import org.springframework.data.annotation.Id; 15 | import org.springframework.data.repository.ListCrudRepository; 16 | 17 | import java.util.List; 18 | 19 | @SpringBootApplication 20 | @RegisterReflectionForBinding ( DogAdoptionSuggestion.class) 21 | public class AiApplication { 22 | 23 | public static void main(String[] args) { 24 | SpringApplication.run(AiApplication.class, args); 25 | } 26 | 27 | @Bean 28 | ApplicationRunner demo(ChatClient cc) { 29 | return _ -> { 30 | var content = cc 31 | .prompt() 32 | .user("do you have any neurotic dogs?") 33 | .call() 34 | .entity( DogAdoptionSuggestion.class); 35 | System.out.println("content [" + content + "]"); 36 | }; 37 | } 38 | 39 | @Bean 40 | ChatClient chatClient( 41 | ChatClient.Builder builder, 42 | @Value("classpath:/my-system-prompt.md") Resource prompt, 43 | DogRepository repository, VectorStore vectorStore) { 44 | 45 | if (false) 46 | repository.findAll().forEach(dog -> { 47 | var dogument = new Document("id: %s, name: %s, description: %s".formatted( 48 | dog.id(), dog.name(), dog.description() 49 | )); 50 | vectorStore.add(List.of(dogument)); 51 | }); 52 | 53 | return builder 54 | .defaultSystem(prompt) 55 | .defaultAdvisors(new QuestionAnswerAdvisor(vectorStore)) 56 | .build(); 57 | } 58 | } 59 | 60 | record Dog(@Id int id, String name, String description) { 61 | } 62 | 63 | interface DogRepository extends ListCrudRepository { 64 | } 65 | 66 | record DogAdoptionSuggestion (int id, String name, String description) {} -------------------------------------------------------------------------------- /integration/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | integration 13 | 0.0.1-SNAPSHOT 14 | integration 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-amqp 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-integration 40 | 41 | 42 | org.springframework.integration 43 | spring-integration-amqp 44 | 45 | 46 | org.springframework.integration 47 | spring-integration-file 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-starter-test 52 | test 53 | 54 | 55 | org.springframework.amqp 56 | spring-rabbit-test 57 | test 58 | 59 | 60 | org.springframework.integration 61 | spring-integration-test 62 | test 63 | 64 | 65 | 66 | 67 | 68 | 69 | org.graalvm.buildtools 70 | native-maven-plugin 71 | 72 | 73 | org.springframework.boot 74 | spring-boot-maven-plugin 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # README 3 | 4 | bit.ly/spring-tips-playlist 5 | youtube.com/@coffeesoftware 6 | 7 | ## Basics 8 | * which IDE? IntelliJ, VSCode, and Eclipse 9 | * your choice of Java: GraalVM 10 | * start.spring.io, an API, website, and an IDE wizard 11 | * Devtools 12 | * Docker Compose 13 | * Testcontainers 14 | * banner.txt 15 | 16 | ## Development Desk Check 17 | * the Spring JavaFormat Plugin 18 | * Python, `gofmt`, your favorite IDE, and 19 | * the power of environment variables 20 | * SDKMAN 21 | * `.sdkman` 22 | * direnv 23 | * `.envrc` 24 | * a good password manager for secrets 25 | 26 | 27 | ## Data Oriented Programming in Java 21+ 28 | * an example 29 | 30 | ## Beans 31 | * dependency injection from first principles 32 | * bean configuration 33 | * XML 34 | * stereotype annotations 35 | * lifecycle 36 | * BeanPostProcessor 37 | * BeanFactoryPostProcessor 38 | * auto configuration 39 | * AOP 40 | * Spring's event publisher 41 | * configuration processor 42 | 43 | ## AOT & GraalVM 44 | * installing GraalVM 45 | * GraalVM native images 46 | * basics 47 | * AOT lifecycles 48 | 49 | ## Data 50 | * `JdbcClient` 51 | * SQL Initialization 52 | * Flyway 53 | * Spring Data JDBC 54 | 55 | ## Batch Processing 56 | * Spring Batch 57 | * load some data from a CSV file to a SQL database 58 | 59 | ## Scalability 60 | * non-blocking IO 61 | * virtual threads 62 | * José Paumard's demo 63 | * Cora Iberkleid's demo 64 | 65 | ## Web Programming 66 | * clients: `RestTemplate`, `RestClient`, declarative interface clients 67 | * REST 68 | * controllers 69 | * functional style 70 | * GraphQL 71 | * batches 72 | 73 | 74 | ## Architecting for Modularity 75 | * Privacy 76 | * Spring Modulith 77 | * Externalized messages 78 | * Testing 79 | 80 | ## Artificial Intelligence 81 | * what's in a model? 82 | * Spring AI 83 | * `ChatClient` 84 | * prompts 85 | * advisors 86 | * Retrieval Augmented Generation (RAG) 87 | 88 | ## Microservices 89 | * centralized configuration 90 | * API gateways 91 | * reactive or not reactive 92 | * event bus and refreshable configuration 93 | * service registration and discovery 94 | 95 | 96 | 97 | ## Messaging and Integration 98 | * "What do you mean by Event Driven?" 99 | * Messaging Technologies like RabbitMQ or Apache Kafka 100 | * Spring Integration 101 | * files to events 102 | 103 | 104 | ## Security 105 | * adding form login to an application 106 | * authentication 107 | * authorization 108 | * passkeys 109 | * one time tokens 110 | * OAuth 111 | * the Spring Authorizatinm Server 112 | * OAuth clients 113 | * OAuth resource servers 114 | * protecting messaging code 115 | 116 | ## Q&A 117 | * I may not know, but I probably know who does know... -------------------------------------------------------------------------------- /basics/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | basics 13 | 0.0.1-SNAPSHOT 14 | basics 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-docker-compose 42 | runtime 43 | true 44 | 45 | 46 | org.postgresql 47 | postgresql 48 | runtime 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-test 53 | test 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-testcontainers 58 | test 59 | 60 | 61 | org.testcontainers 62 | junit-jupiter 63 | test 64 | 65 | 66 | org.testcontainers 67 | postgresql 68 | test 69 | 70 | 71 | org.springframework.boot 72 | spring-boot-starter-jdbc 73 | 74 | 75 | org.springframework.boot 76 | spring-boot-devtools 77 | runtime 78 | 79 | 80 | 81 | 82 | 83 | 84 | org.springframework.boot 85 | spring-boot-maven-plugin 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /security/misc/legacy-schema.sql: -------------------------------------------------------------------------------- 1 | drop table if exists authorities; 2 | drop table if exists users; 3 | -- INSTRUCTIONS: 4 | -- start Docker Compose 5 | -- cat legacy-schema.sql | PGPASSWORD=secret psql -U myuser -h localhost mydatabase 6 | -- 7 | -- PostgreSQL database dump 8 | -- 9 | 10 | -- Dumped from database version 16.3 (Debian 16.3-1.pgdg120+1) 11 | -- Dumped by pg_dump version 16.3 12 | 13 | SET statement_timeout = 0; 14 | SET lock_timeout = 0; 15 | SET idle_in_transaction_session_timeout = 0; 16 | SET client_encoding = 'UTF8'; 17 | SET standard_conforming_strings = on; 18 | SELECT pg_catalog.set_config('search_path', '', false); 19 | SET check_function_bodies = false; 20 | SET xmloption = content; 21 | SET client_min_messages = warning; 22 | SET row_security = off; 23 | 24 | SET default_tablespace = ''; 25 | 26 | SET default_table_access_method = heap; 27 | 28 | -- 29 | -- Name: authorities; Type: TABLE; Schema: public; Owner: myuser 30 | -- 31 | 32 | CREATE TABLE public.authorities ( 33 | username text NOT NULL, 34 | authority text NOT NULL 35 | ); 36 | 37 | 38 | ALTER TABLE public.authorities OWNER TO myuser; 39 | 40 | -- 41 | -- Name: users; Type: TABLE; Schema: public; Owner: myuser 42 | -- 43 | 44 | CREATE TABLE public.users ( 45 | username text NOT NULL, 46 | password text NOT NULL, 47 | enabled boolean NOT NULL 48 | ); 49 | 50 | 51 | ALTER TABLE public.users OWNER TO myuser; 52 | 53 | -- 54 | -- Data for Name: authorities; Type: TABLE DATA; Schema: public; Owner: myuser 55 | -- 56 | 57 | COPY public.authorities (username, authority) FROM stdin; 58 | josh ROLE_USER 59 | rob ROLE_ADMIN 60 | rob ROLE_USER 61 | \. 62 | 63 | 64 | -- 65 | -- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: myuser 66 | -- 67 | 68 | COPY public.users (username, password, enabled) FROM stdin; 69 | josh 843b103f6c09de407d366f8ff6553691767a35dbaf870cad47e86945c4103be85ee8ea49509b9502 t 70 | rob a94f80ed1a6677dedb489a6912e6c83a7c2a7ada2c4d739dd4a4ab9e454d3d875134fa4480b19c55 t 71 | \. 72 | 73 | 74 | -- 75 | -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: myuser 76 | -- 77 | 78 | ALTER TABLE ONLY public.users 79 | ADD CONSTRAINT users_pkey PRIMARY KEY (username); 80 | 81 | 82 | -- 83 | -- Name: ix_auth_username; Type: INDEX; Schema: public; Owner: myuser 84 | -- 85 | 86 | CREATE UNIQUE INDEX ix_auth_username ON public.authorities USING btree (username, authority); 87 | 88 | 89 | -- 90 | -- Name: authorities fk_authorities_users; Type: FK CONSTRAINT; Schema: public; Owner: myuser 91 | -- 92 | 93 | ALTER TABLE ONLY public.authorities 94 | ADD CONSTRAINT fk_authorities_users FOREIGN KEY (username) REFERENCES public.users(username); 95 | 96 | 97 | -- 98 | -- PostgreSQL database dump complete 99 | -- 100 | 101 | -------------------------------------------------------------------------------- /aot/src/main/java/com/example/aot/AotApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.aot; 2 | 3 | import org.springframework.aot.hint.MemberCategory; 4 | import org.springframework.aot.hint.RuntimeHints; 5 | import org.springframework.aot.hint.RuntimeHintsRegistrar; 6 | import org.springframework.boot.ApplicationArguments; 7 | import org.springframework.boot.ApplicationRunner; 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | import org.springframework.context.annotation.ImportRuntimeHints; 13 | import org.springframework.core.io.ClassPathResource; 14 | import org.springframework.core.io.Resource; 15 | 16 | import java.nio.charset.Charset; 17 | 18 | @SpringBootApplication 19 | public class AotApplication { 20 | 21 | public static void main(String[] args) { 22 | SpringApplication.run(AotApplication.class, args); 23 | } 24 | 25 | 26 | } 27 | 28 | class MessageRunner implements ApplicationRunner { 29 | 30 | private final Resource resource; 31 | 32 | MessageRunner(Resource resource) { 33 | this.resource = resource; 34 | } 35 | 36 | @Override 37 | public void run(ApplicationArguments args) throws Exception { 38 | var contents = this.resource.getContentAsString(Charset.defaultCharset()); 39 | System.out.println("contents [" + contents + "]"); 40 | } 41 | } 42 | 43 | 44 | class Foo { 45 | 46 | int x = 0; 47 | 48 | void bar() { 49 | System.out.println("invoking bar"); 50 | } 51 | } 52 | 53 | class ReflectiveThingy { 54 | 55 | ReflectiveThingy() { 56 | 57 | var fooClass = Foo.class; 58 | for (var field : fooClass.getDeclaredFields()) 59 | System.out.println("field [" + field + "]"); 60 | 61 | for (var method : fooClass.getDeclaredMethods()) 62 | System.out.println("method [" + method + "]"); 63 | } 64 | } 65 | 66 | @Configuration 67 | @ImportRuntimeHints(AotConfiguration.Hints.class) 68 | //@RegisterReflectionForBinding(ReflectiveThingy.class) 69 | class AotConfiguration { 70 | 71 | 72 | private static final Resource RESOURCE = new ClassPathResource("message"); 73 | 74 | static class Hints implements RuntimeHintsRegistrar { 75 | 76 | @Override 77 | public void registerHints(RuntimeHints hints, ClassLoader classLoader) { 78 | hints.reflection().registerType(Foo.class, MemberCategory.values()); 79 | hints.resources().registerResource(RESOURCE); 80 | } 81 | } 82 | 83 | @Bean 84 | MessageRunner messageRunner() { 85 | return new MessageRunner(RESOURCE); 86 | } 87 | 88 | @Bean 89 | ReflectiveThingy reflectiveThingy() { 90 | return new ReflectiveThingy(); 91 | } 92 | } 93 | 94 | -------------------------------------------------------------------------------- /scalability/src/main/java/com/example/scalability/ScalabilityApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.scalability; 2 | 3 | import org.springframework.boot.ApplicationRunner; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.ResponseBody; 11 | import org.springframework.web.client.RestClient; 12 | 13 | import java.util.ArrayList; 14 | import java.util.concurrent.ConcurrentSkipListSet; 15 | import java.util.concurrent.Executors; 16 | import java.util.concurrent.Future; 17 | 18 | @SpringBootApplication 19 | public class ScalabilityApplication { 20 | 21 | public static void main(String[] args) { 22 | SpringApplication.run(ScalabilityApplication.class, args); 23 | } 24 | 25 | @Bean 26 | ApplicationRunner josePaumardsDemo() { 27 | return _ -> { 28 | 29 | var futures = new ArrayList>(); 30 | var threads = new ConcurrentSkipListSet(); 31 | // var executor = Executors.newCachedThreadPool(); 32 | var executor = Executors.newVirtualThreadPerTaskExecutor(); 33 | for (var i = 0; i < 1000; i++) { 34 | var first = i == 0; 35 | futures.add(executor.submit(() -> { 36 | sleep(threads, first); 37 | sleep(threads, first); 38 | sleep(threads, first); 39 | })); 40 | } 41 | 42 | for (var f : futures) { 43 | f.get(); 44 | } 45 | System.out.println(threads); 46 | 47 | }; 48 | } 49 | 50 | 51 | private void sleep(ConcurrentSkipListSet threads, boolean first) { 52 | if (first) { 53 | threads.add(Thread.currentThread().toString()); 54 | } 55 | try { 56 | Thread.sleep(200); 57 | } catch (InterruptedException e) { 58 | throw new RuntimeException(e); 59 | } 60 | if (first) { 61 | threads.add(Thread.currentThread().toString()); 62 | } 63 | } 64 | } 65 | 66 | // cora iberkleid's demo 67 | @Configuration 68 | class DelayConfiguration { 69 | 70 | @Bean 71 | RestClient http(RestClient.Builder builder) { 72 | return builder.build(); 73 | } 74 | } 75 | 76 | @Controller 77 | @ResponseBody 78 | class DelayController { 79 | 80 | private final RestClient http; 81 | 82 | DelayController(RestClient http) { 83 | this.http = http; 84 | } 85 | 86 | @GetMapping("/wait") 87 | String delay() { 88 | return this.http.get().uri("https://httpbin.org/delay/5").retrieve().body(String.class); 89 | } 90 | } -------------------------------------------------------------------------------- /modularity/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | modularity 13 | 0.0.1-SNAPSHOT 14 | modularity 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 1.2.3 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-data-jdbc 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-web 41 | 42 | 43 | org.springframework.modulith 44 | spring-modulith-starter-core 45 | 46 | 47 | org.springframework.modulith 48 | spring-modulith-starter-jdbc 49 | 50 | 51 | org.postgresql 52 | postgresql 53 | runtime 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-starter-test 58 | test 59 | 60 | 61 | org.springframework.modulith 62 | spring-modulith-starter-test 63 | test 64 | 65 | 66 | 67 | 68 | 69 | org.springframework.modulith 70 | spring-modulith-bom 71 | ${spring-modulith.version} 72 | pom 73 | import 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | org.graalvm.buildtools 82 | native-maven-plugin 83 | 84 | 85 | org.springframework.boot 86 | spring-boot-maven-plugin 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /batch/src/main/java/com/example/batch/BatchApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.batch; 2 | 3 | import org.springframework.batch.core.Job; 4 | import org.springframework.batch.core.Step; 5 | import org.springframework.batch.core.job.builder.JobBuilder; 6 | import org.springframework.batch.core.repository.JobRepository; 7 | import org.springframework.batch.core.step.builder.StepBuilder; 8 | import org.springframework.batch.item.database.JdbcBatchItemWriter; 9 | import org.springframework.batch.item.database.builder.JdbcBatchItemWriterBuilder; 10 | import org.springframework.batch.item.file.FlatFileItemReader; 11 | import org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder; 12 | import org.springframework.batch.item.file.transform.DelimitedLineTokenizer; 13 | import org.springframework.beans.factory.annotation.Value; 14 | import org.springframework.boot.SpringApplication; 15 | import org.springframework.boot.autoconfigure.SpringBootApplication; 16 | import org.springframework.context.annotation.Bean; 17 | import org.springframework.core.io.Resource; 18 | import org.springframework.transaction.PlatformTransactionManager; 19 | 20 | import javax.sql.DataSource; 21 | 22 | @SpringBootApplication 23 | public class BatchApplication { 24 | 25 | public static void main(String[] args) { 26 | SpringApplication.run(BatchApplication.class, args); 27 | } 28 | 29 | @Bean 30 | FlatFileItemReader flatFileItemReader(@Value("classpath:/input.csv") Resource resource) { 31 | return new FlatFileItemReaderBuilder() 32 | // .lineTokenizer(new DelimitedLineTokenizer(",")) 33 | .resource(resource) 34 | .name("csvFlatFileItemReader") 35 | .linesToSkip(1) 36 | .delimited().names("id", "name") 37 | .fieldSetMapper(fieldSet -> new Customer(fieldSet.readInt( "id"), fieldSet.readString("name"))) 38 | .build(); 39 | } 40 | 41 | @Bean 42 | JdbcBatchItemWriter jdbcBatchItemWriter(DataSource dataSource) { 43 | return new JdbcBatchItemWriterBuilder() 44 | .assertUpdates(true) 45 | .dataSource(dataSource) 46 | .sql("insert into customer (id,name) values (?,?)") 47 | .itemPreparedStatementSetter((item, ps) -> { 48 | ps.setInt(1, item.id()); 49 | ps.setString(2, item.name()); 50 | }) 51 | .build(); 52 | } 53 | 54 | @Bean 55 | Step start(JobRepository repository, PlatformTransactionManager transactionManager, 56 | FlatFileItemReader reader, JdbcBatchItemWriter writer) { 57 | return new StepBuilder("startStep", repository) 58 | .chunk(10, transactionManager) 59 | .reader(reader) 60 | .writer(writer) 61 | .build(); 62 | } 63 | 64 | @Bean 65 | Job job(JobRepository repository, Step start) { 66 | return new JobBuilder("csvToDbJob", repository) 67 | .start(start) 68 | .build(); 69 | } 70 | 71 | } 72 | 73 | record Customer(int id, String name) { 74 | } -------------------------------------------------------------------------------- /web/src/main/java/com/example/web/Clients.java: -------------------------------------------------------------------------------- 1 | package com.example.web; 2 | 3 | import org.springframework.boot.ApplicationRunner; 4 | import org.springframework.boot.web.client.RestTemplateBuilder; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.http.client.JdkClientHttpRequestFactory; 8 | import org.springframework.util.Assert; 9 | import org.springframework.web.client.RestClient; 10 | import org.springframework.web.client.RestTemplate; 11 | import org.springframework.web.client.support.RestClientAdapter; 12 | import org.springframework.web.service.annotation.GetExchange; 13 | import org.springframework.web.service.invoker.HttpServiceProxyFactory; 14 | 15 | @Configuration 16 | class Clients { 17 | 18 | record Slide(String title, String type) { 19 | } 20 | 21 | record Slideshow(String author, String date, Slide[] slides) { 22 | } 23 | 24 | record Response(Slideshow slideshow) { 25 | } 26 | 27 | 28 | void validate(Class clzz, Response response) { 29 | Assert.notNull(response, "response must not be null"); 30 | Assert.notNull(response.slideshow(), "slideshow must not be null"); 31 | Assert.notNull(response.slideshow().slides(), "slideshow slides must not be null"); 32 | Assert.notNull(response.slideshow().slides().length > 0, "slideshow slides length must not be null"); 33 | System.out.println("=========================================="); 34 | System.out.println("type: " + clzz.getName()); 35 | for (var slide : response.slideshow().slides()) { 36 | System.out.println("slide : " + slide.toString()); 37 | } 38 | } 39 | 40 | @Bean 41 | ApplicationRunner clientRunner(RestTemplate restTemplate, 42 | RestClient restClient, 43 | SlideshowClient slideshowClient) { 44 | return _ -> { 45 | var url = "https://httpbin.org/json"; 46 | 47 | this.validate(RestTemplate.class, restTemplate.getForObject(url, Response.class)); 48 | this.validate(RestClient.class, restClient.get().uri(url).retrieve().body(Response.class)); 49 | this.validate(SlideshowClient.class, slideshowClient.get()); 50 | }; 51 | } 52 | 53 | @Bean 54 | JdkClientHttpRequestFactory jdkClientHttpRequestFactory() { 55 | return new JdkClientHttpRequestFactory(); 56 | } 57 | 58 | @Bean 59 | RestClient restClient( 60 | JdkClientHttpRequestFactory jdkClientHttpRequestFactory, 61 | RestClient.Builder builder) { 62 | return builder 63 | .requestFactory(jdkClientHttpRequestFactory) 64 | .build(); 65 | } 66 | 67 | @Bean 68 | RestTemplate restTemplate( 69 | JdkClientHttpRequestFactory jdkClientHttpRequestFactory, 70 | RestTemplateBuilder builder) { 71 | return builder 72 | .requestFactory(() -> jdkClientHttpRequestFactory) 73 | .build(); 74 | } 75 | 76 | @Bean 77 | SlideshowClient slideshowClient(RestClient restClient) { 78 | return HttpServiceProxyFactory 79 | .builderFor(RestClientAdapter.create(restClient)) 80 | .build() 81 | .createClient(SlideshowClient.class); 82 | } 83 | } 84 | 85 | interface SlideshowClient { 86 | 87 | @GetExchange("https://httpbin.org/json") 88 | Clients.Response get(); 89 | } -------------------------------------------------------------------------------- /security/passwordless/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.3 9 | 10 | 11 | bootiful 12 | passwordless 13 | 0.0.1-SNAPSHOT 14 | passwordless 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 21 31 | 6.4.0-SNAPSHOT 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-jdbc 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-security 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-web 45 | 46 | 47 | 52 | 53 | io.github.rwinch.webauthn 54 | spring-security-webauthn 55 | 0.0.1-SNAPSHOT 56 | 57 | 58 | 59 | org.postgresql 60 | postgresql 61 | runtime 62 | 63 | 64 | org.springframework.boot 65 | spring-boot-starter-test 66 | test 67 | 68 | 69 | org.springframework.security 70 | spring-security-test 71 | test 72 | 73 | 74 | org.springframework.boot 75 | spring-boot-starter-oauth2-authorization-server 76 | 77 | 78 | 79 | 80 | 81 | 82 | org.graalvm.buildtools 83 | native-maven-plugin 84 | 85 | 86 | org.springframework.boot 87 | spring-boot-maven-plugin 88 | 89 | 90 | 91 | 92 | 93 | 94 | spring-snapshot 95 | https://repo.spring.io/snapshot 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /ai/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.example 12 | ai 13 | 0.0.1-SNAPSHOT 14 | ai 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 23 31 | 1.0.0-M2 32 | 2023.0.3 33 | 34 | 35 | 36 | org.springframework.ai 37 | spring-ai-openai-spring-boot-starter 38 | 39 | 40 | org.springframework.ai 41 | spring-ai-pgvector-store-spring-boot-starter 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-docker-compose 47 | runtime 48 | true 49 | 50 | 51 | org.springframework.ai 52 | spring-ai-spring-boot-docker-compose 53 | ${spring-ai.version} 54 | runtime 55 | true 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-starter-test 60 | test 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-starter-data-jdbc 65 | 66 | 67 | org.springframework.boot 68 | spring-boot-starter-web 69 | 70 | 71 | org.springframework.cloud 72 | spring-cloud-function-web 73 | 74 | 75 | 76 | 77 | 78 | org.springframework.ai 79 | spring-ai-bom 80 | ${spring-ai.version} 81 | pom 82 | import 83 | 84 | 85 | org.springframework.cloud 86 | spring-cloud-dependencies 87 | ${spring-cloud.version} 88 | pom 89 | import 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | org.graalvm.buildtools 98 | native-maven-plugin 99 | 100 | 101 | org.springframework.boot 102 | spring-boot-maven-plugin 103 | 104 | 105 | 106 | 107 | 108 | spring-milestones 109 | Spring Milestones 110 | https://repo.spring.io/milestone 111 | 112 | false 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /ai/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | delete from dog; 2 | 3 | INSERT INTO dog (id, name, description, dob, gender, image) 4 | VALUES (97, 'Rocky', 'A brown Chihuahua known for being protective.', '2019-01-28', 'M', 5 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/chihuahua-1.png'); 6 | 7 | INSERT INTO dog (id, name, description, dob, gender, image) 8 | VALUES (87, 'Bailey', 'A tan Dachshund known for being playful.', '2022-03-22', 'M', 9 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/dachshund-1.png'); 10 | 11 | INSERT INTO dog (id, name, description, dob, gender, image) 12 | VALUES (89, 'Charlie', 'A black Bulldog known for being curious.', '2021-08-26', 'M', 13 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/bulldog-1.png'); 14 | 15 | INSERT INTO dog (id, name, description, dob, gender, image) 16 | VALUES (67, 'Cooper', 'A tan Boxer known for being affectionate.', '2011-12-22', 'F', 17 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/boxer-1.png'); 18 | 19 | INSERT INTO dog (id, name, description, dob, gender, image) 20 | VALUES (73, 'Max', 'A brindle Dachshund known for being energetic.', '2021-12-07', 'M', 21 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/dachshund-1.png'); 22 | 23 | INSERT INTO dog (id, name, description, dob, gender, image) 24 | VALUES (3, 'Buddy', 'A Poodle known for being calm.', '2013-10-30', 'M', 25 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/poodle-1.png'); 26 | 27 | INSERT INTO dog (id, name, description, dob, gender, image) 28 | VALUES (93, 'Duke', 'A white German Shepherd known for being friendly.', '2017-03-19', 'M', 29 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/german-shepard-2.png'); 30 | 31 | INSERT INTO dog (id, name, description, dob, gender, image) 32 | VALUES (63, 'Jasper', 'A grey Shih Tzu known for being protective.', '2016-01-05', 'M', 33 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/shih-tzu-2.png'); 34 | 35 | INSERT INTO dog (id, name, description, dob, gender, image) 36 | VALUES (69, 'Toby', 'A grey Doberman known for being playful.', '2008-12-31', 'M', 37 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/doberman-1.png'); 38 | 39 | INSERT INTO dog (id, name, description, dob, gender, image) 40 | VALUES (101, 'Nala', 'A spotted German Shepherd known for being loyal.', '2020-07-30', 'F', 41 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/german-shepard-1.png'); 42 | 43 | INSERT INTO dog (id, name, description, dob, gender, image) 44 | VALUES (61, 'Penny', 'A white Great Dane known for being protective.', '2014-05-07', 'F', 45 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/great-dane-1.png'); 46 | 47 | INSERT INTO dog (id, name, description, dob, gender, image) 48 | VALUES (1, 'Bella', 'A golden Poodle known for being calm.', '2020-01-07', 'F', 49 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/poodle-2.png'); 50 | 51 | INSERT INTO dog (id, name, description, dob, gender, image) 52 | VALUES (91, 'Willow', 'A brindle Great Dane known for being calm.', '2011-11-15', 'F', 53 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/great-dane-2.png'); 54 | 55 | INSERT INTO dog (id, name, description, dob, gender, image) 56 | VALUES (5, 'Daisy', 'A spotted Poodle known for being affectionate.', '2021-07-31', 'F', 57 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/poodle-1.png'); 58 | 59 | INSERT INTO dog (id, name, description, dob, gender, image) 60 | VALUES (95, 'Mia', 'A grey Great Dane known for being loyal.', '2020-11-03', 'F', 61 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/great-dane-2.png'); 62 | 63 | INSERT INTO dog (id, name, description, dob, gender, image) 64 | VALUES (71, 'Molly', 'A golden Chihuahua known for being curious.', '2014-03-22', 'F', 65 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/chihuahua-2.png'); 66 | 67 | INSERT INTO dog (id, name, description, dob, gender, image) 68 | VALUES (65, 'Ruby', 'A white Great Dane known for being protective.', '2021-11-07', 'F', 69 | 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/great-dane-3.png'); 70 | 71 | INSERT INTO dog (id, name, description, dob, gender, image) 72 | VALUES (45, 'Prancer', 'A demonic, neurotic, man hating, animal hating, children hating dogs that look like gremlins.', 73 | '2008-12-19', 'M', 'https://raw.githubusercontent.com/joshlong-attic/dog-images/main/prancer.jpg'); 74 | -- 75 | -- Name: dog_id_seq; Type: SEQUENCE SET; Schema: public; Owner: myuser 76 | -- 77 | 78 | SELECT pg_catalog.setval('public.dog_id_seq', 101, true); -------------------------------------------------------------------------------- /security/passwordless/src/main/java/bootiful/passwordless/PasswordlessApplication.java: -------------------------------------------------------------------------------- 1 | package bootiful.passwordless; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.core.annotation.Order; 7 | import org.springframework.http.MediaType; 8 | import org.springframework.security.config.Customizer; 9 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 | import org.springframework.security.core.userdetails.User; 11 | import org.springframework.security.core.userdetails.UserDetailsPasswordService; 12 | import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration; 13 | import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer; 14 | import org.springframework.security.provisioning.JdbcUserDetailsManager; 15 | import org.springframework.security.web.SecurityFilterChain; 16 | import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint; 17 | import org.springframework.security.web.util.matcher.MediaTypeRequestMatcher; 18 | import org.springframework.stereotype.Controller; 19 | import org.springframework.web.bind.annotation.GetMapping; 20 | import org.springframework.web.bind.annotation.ResponseBody; 21 | 22 | import javax.sql.DataSource; 23 | import java.security.Principal; 24 | import java.util.Map; 25 | 26 | import static org.springframework.security.config.annotation.web.configurers.WebauthnConfigurer.webauthn; 27 | 28 | @SpringBootApplication 29 | public class PasswordlessApplication { 30 | 31 | public static void main(String[] args) { 32 | SpringApplication.run(PasswordlessApplication.class, args); 33 | } 34 | 35 | @Bean 36 | JdbcUserDetailsManager jdbcUserDetailsManager(DataSource dataSource) { 37 | return new JdbcUserDetailsManager(dataSource); 38 | } 39 | 40 | @Bean 41 | UserDetailsPasswordService userDetailsPasswordService(JdbcUserDetailsManager userDetailsManager) { 42 | return (user, newPassword) -> { 43 | var updated = User.withUserDetails(user).password(newPassword).build(); 44 | userDetailsManager.updateUser(updated); 45 | return updated; 46 | }; 47 | } 48 | 49 | @Bean 50 | @Order(1) 51 | SecurityFilterChain authServerFilterChain(HttpSecurity http) throws Exception { 52 | OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http); 53 | http.getConfigurer(OAuth2AuthorizationServerConfigurer.class) 54 | .oidc(Customizer.withDefaults()); 55 | http 56 | .exceptionHandling((exceptions) -> exceptions 57 | .defaultAuthenticationEntryPointFor( 58 | new LoginUrlAuthenticationEntryPoint("/login"), 59 | new MediaTypeRequestMatcher(MediaType.TEXT_HTML) 60 | ) 61 | ) 62 | .oauth2ResourceServer((resourceServer) -> resourceServer.jwt(Customizer.withDefaults())); 63 | return http.build(); 64 | } 65 | 66 | @Bean 67 | SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception { 68 | return httpSecurity 69 | .authorizeHttpRequests(requests -> requests 70 | .requestMatchers("/admin").hasRole("ADMIN") 71 | .requestMatchers("/error").permitAll() 72 | .anyRequest().authenticated() 73 | ) 74 | .oneTimeTokenLogin(configurer -> configurer.generatedOneTimeTokenSuccessHandler((request, response, oneTimeToken) -> { 75 | var msg = "go to http://localhost:8080/login/ott?token=" + oneTimeToken.getTokenValue(); 76 | System.out.println(msg); 77 | response.setContentType(MediaType.TEXT_PLAIN_VALUE); 78 | response.getWriter().print("you've got console mail!"); 79 | })) 80 | .with(webauthn(), c -> c 81 | .rpId("localhost") 82 | .rpName("bootiful passkeys") 83 | .allowedOrigins("http://localhost:8080") 84 | ) 85 | .formLogin(Customizer.withDefaults()) 86 | .build(); 87 | } 88 | } 89 | 90 | @Controller 91 | @ResponseBody 92 | class SecuredController { 93 | 94 | @GetMapping("/admin") 95 | Map admin(Principal principal) { 96 | return Map.of("admin", principal.getName()); 97 | } 98 | 99 | @GetMapping("/") 100 | Map hello(Principal principal) { 101 | return Map.of("user", principal.getName()); 102 | } 103 | } -------------------------------------------------------------------------------- /basics/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ${AnsiColor.BRIGHT_BLUE}████████████████████████████████████████████████████████████████████████████████ 2 | ${AnsiColor.BRIGHT_BLUE}████████████████████████████████████████████████████████████████████████████████ 3 | ${AnsiColor.RED}██████████████████${AnsiColor.BRIGHT_BLUE}████████████████${AnsiColor.BLACK}██████████████████████████████${AnsiColor.BRIGHT_BLUE}████████████████ 4 | ${AnsiColor.RED}████████████████████████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██████████████████████████████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}██████████████ 5 | ${AnsiColor.BRIGHT_RED}████${AnsiColor.RED}██████████████████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██████${AnsiColor.MAGENTA}██████████████████████${AnsiColor.WHITE}██████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}████████████ 6 | ${AnsiColor.BRIGHT_RED}██████████████████████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}████${AnsiColor.MAGENTA}████████████████${AnsiColor.BLACK}████${AnsiColor.MAGENTA}██████${AnsiColor.WHITE}████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}██${AnsiColor.BLACK}████${AnsiColor.BRIGHT_BLUE}██████ 7 | ${AnsiColor.BRIGHT_RED}██████████████████████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██${AnsiColor.MAGENTA}████████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}████${AnsiColor.BLACK}██${AnsiColor.MAGENTA}██████${AnsiColor.WHITE}██${AnsiColor.BLACK}████${AnsiColor.WHITE}████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}████ 8 | ${AnsiColor.BRIGHT_YELLOW}██████████████████${AnsiColor.BRIGHT_RED}████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██${AnsiColor.MAGENTA}████████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██████${AnsiColor.MAGENTA}██████${AnsiColor.WHITE}██${AnsiColor.BLACK}██${AnsiColor.WHITE}██████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}████ 9 | ${AnsiColor.BRIGHT_YELLOW}██████████████████████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_YELLOW}██████${AnsiColor.BLACK}██${AnsiColor.WHITE}██${AnsiColor.MAGENTA}████████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██████${AnsiColor.BLACK}████████${AnsiColor.WHITE}████████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}████ 10 | ${AnsiColor.BRIGHT_YELLOW}████████████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██${AnsiColor.BLACK}██${AnsiColor.BRIGHT_YELLOW}████${AnsiColor.BLACK}██${AnsiColor.WHITE}██${AnsiColor.MAGENTA}████████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██████████████████████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}████ 11 | ${AnsiColor.BRIGHT_GREEN}██████████████████${AnsiColor.BRIGHT_YELLOW}██${AnsiColor.BLACK}██${AnsiColor.WHITE}██${AnsiColor.BLACK}████████${AnsiColor.WHITE}██${AnsiColor.MAGENTA}██████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██████████████████████████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}██ 12 | ${AnsiColor.BRIGHT_GREEN}██████████████████████${AnsiColor.WHITE}████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██${AnsiColor.MAGENTA}██████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██████${AnsiColor.BRIGHT_YELLOW}██${AnsiColor.WHITE}██████████${AnsiColor.BRIGHT_YELLOW}██${AnsiColor.BLACK}██${AnsiColor.WHITE}████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}██ 13 | ${AnsiColor.BRIGHT_GREEN}██████████████████████${AnsiColor.BLACK}████${AnsiColor.WHITE}████${AnsiColor.BLACK}██${AnsiColor.WHITE}██${AnsiColor.MAGENTA}██████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██████${AnsiColor.BLACK}██${AnsiColor.WHITE}██████${AnsiColor.BLACK}██${AnsiColor.WHITE}██${AnsiColor.BLACK}████${AnsiColor.WHITE}████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}██ 14 | ${AnsiColor.BLUE}██████████████████${AnsiColor.BRIGHT_GREEN}████████${AnsiColor.BLACK}██████${AnsiColor.WHITE}██${AnsiColor.MAGENTA}██████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██${AnsiColor.MAGENTA}████${AnsiColor.WHITE}████████████████${AnsiColor.MAGENTA}████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}██ 15 | ${AnsiColor.BLUE}██████████████████████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}████${AnsiColor.MAGENTA}██████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██████${AnsiColor.BLACK}████████████${AnsiColor.WHITE}████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}████ 16 | ${AnsiColor.BRIGHT_BLUE}██████████████████${AnsiColor.BLUE}████${AnsiColor.BLUE}██████${AnsiColor.BLACK}████${AnsiColor.WHITE}██████${AnsiColor.MAGENTA}██████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██████████████████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}██████ 17 | ${AnsiColor.BRIGHT_BLUE}██████████████████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██${AnsiColor.BLACK}████${AnsiColor.WHITE}████████████████████${AnsiColor.BLACK}██████████████████${AnsiColor.BRIGHT_BLUE}████████ 18 | ${AnsiColor.BRIGHT_BLUE}████████████████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}██████${AnsiColor.BLACK}████████████████████████████████${AnsiColor.WHITE}██${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}████████████ 19 | ${AnsiColor.BRIGHT_BLUE}████████████████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}██${AnsiColor.BLACK}██${AnsiColor.WHITE}████${AnsiColor.BRIGHT_BLUE}████████████${AnsiColor.BLACK}██${AnsiColor.WHITE}████${AnsiColor.BLACK}████${AnsiColor.WHITE}████${AnsiColor.BLACK}██${AnsiColor.BRIGHT_BLUE}████████████ 20 | ${AnsiColor.BRIGHT_BLUE}████████████████████████${AnsiColor.BLACK}██████${AnsiColor.BRIGHT_BLUE}████${AnsiColor.BLACK}██████${AnsiColor.BRIGHT_BLUE}████████████${AnsiColor.BLACK}██████${AnsiColor.BRIGHT_BLUE}████${AnsiColor.BLACK}██████${AnsiColor.BRIGHT_BLUE}████████████ 21 | ████████████████████████████████████████████████████████████████████████████████ 22 | ${AnsiColor.BRIGHT_BLUE}:: Meow :: Running Spring Boot ${spring-boot.version} :: \ö/${AnsiColor.BLACK} -------------------------------------------------------------------------------- /beans/src/main/java/com/example/beans/BeansApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.beans; 2 | 3 | import org.aopalliance.intercept.MethodInterceptor; 4 | import org.aopalliance.intercept.MethodInvocation; 5 | import org.springframework.aop.framework.ProxyFactory; 6 | import org.springframework.beans.BeansException; 7 | import org.springframework.beans.factory.config.BeanFactoryPostProcessor; 8 | import org.springframework.beans.factory.config.BeanPostProcessor; 9 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; 10 | import org.springframework.boot.ApplicationArguments; 11 | import org.springframework.boot.ApplicationRunner; 12 | import org.springframework.boot.SpringApplication; 13 | import org.springframework.boot.autoconfigure.SpringBootApplication; 14 | import org.springframework.boot.context.event.ApplicationReadyEvent; 15 | import org.springframework.boot.context.properties.ConfigurationProperties; 16 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 17 | import org.springframework.context.ApplicationEventPublisher; 18 | import org.springframework.context.ApplicationListener; 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.Configuration; 21 | import org.springframework.context.event.EventListener; 22 | import org.springframework.stereotype.Component; 23 | import org.springframework.stereotype.Service; 24 | import org.springframework.util.Assert; 25 | 26 | import java.util.Arrays; 27 | 28 | @EnableConfigurationProperties(BootifulProperties.class) 29 | @SpringBootApplication 30 | public class BeansApplication { 31 | 32 | public static void main(String[] args) throws BeansException { 33 | // var context = new ClassPathXmlApplicationContext("beans.xml"); 34 | // context.start(); 35 | 36 | // var context = new AnnotationConfigApplicationContext(BeansApplication.class); 37 | // context.start(); 38 | 39 | var context = SpringApplication.run(BeansApplication.class, args); 40 | 41 | } 42 | 43 | @Bean 44 | Bar bar(Foo foo) { 45 | return new Bar(foo); 46 | } 47 | 48 | @Bean 49 | static BPP bpp() { 50 | return new BPP(); 51 | } 52 | 53 | @Bean 54 | static BFPP bfpp() { 55 | return new BFPP(); 56 | } 57 | 58 | @Bean 59 | static LoggingInterceptor loggingInterceptor() { 60 | return new LoggingInterceptor(); 61 | } 62 | 63 | } 64 | 65 | record CustomerValidatedEvent(String name) { 66 | } 67 | 68 | @Component 69 | class ValidationListener { 70 | 71 | @EventListener 72 | void onCustomerValidatedEvent(CustomerValidatedEvent event) { 73 | System.out.println("got a CustomerValidatedEvent: " + event); 74 | } 75 | } 76 | 77 | @Component 78 | class ReadyListener implements ApplicationListener { 79 | 80 | @Override 81 | public void onApplicationEvent(ApplicationReadyEvent event) { 82 | System.out.println("the application is ready.."); 83 | } 84 | } 85 | 86 | @Configuration 87 | class PropertiesConfiguration { 88 | 89 | @Bean 90 | PropertiesRunner propertiesRunner(BootifulProperties properties) { 91 | return new PropertiesRunner(properties.name()); 92 | } 93 | } 94 | 95 | class PropertiesRunner implements ApplicationRunner { 96 | 97 | private final String name; 98 | 99 | PropertiesRunner(String name) { 100 | this.name = name; 101 | } 102 | 103 | @Override 104 | public void run(ApplicationArguments args) throws Exception { 105 | System.out.println("name: " + this.name); 106 | } 107 | } 108 | 109 | @Component 110 | class Initializer implements ApplicationRunner { 111 | 112 | private final CustomerService customerService; 113 | 114 | Initializer(CustomerService customerService) { 115 | this.customerService = customerService; 116 | } 117 | 118 | @Override 119 | public void run(ApplicationArguments args) throws Exception { 120 | this.customerService.validate("foo"); 121 | } 122 | } 123 | 124 | class LoggingInterceptor implements BeanPostProcessor { 125 | 126 | private final MI mi = new MI(); 127 | 128 | @Override 129 | public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { 130 | if (bean instanceof CustomerService) { 131 | var pf = new ProxyFactory(bean); 132 | pf.addAdvice(mi); 133 | pf.setProxyTargetClass(true); 134 | return pf.getProxy(); 135 | } 136 | return bean; 137 | } 138 | } 139 | 140 | @Service 141 | class CustomerService { 142 | 143 | private final ApplicationEventPublisher publisher; 144 | 145 | CustomerService(ApplicationEventPublisher publisher) { 146 | this.publisher = publisher; 147 | } 148 | 149 | boolean validate(String name) { 150 | System.out.println("isCustomer(" + name + ")"); 151 | this.publisher.publishEvent(new CustomerValidatedEvent(name)); 152 | return true; 153 | } 154 | } 155 | 156 | class MI implements MethodInterceptor { 157 | 158 | @Override 159 | public Object invoke(MethodInvocation invocation) throws Throwable { 160 | System.out.println("========================================================"); 161 | System.out.println("invoking [" + invocation.getMethod().getName() + 162 | " with arguments [" + Arrays.toString(invocation.getArguments()) + "]"); 163 | return invocation.proceed(); 164 | } 165 | } 166 | 167 | class BFPP implements BeanFactoryPostProcessor { 168 | 169 | @Override 170 | public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { 171 | for (var beanDefinitionName : beanFactory.getBeanDefinitionNames()) 172 | System.out.println("beanDefinitionName [" + beanDefinitionName + ":" + 173 | beanFactory.getBeanDefinition(beanDefinitionName).getBeanClassName() + "]"); 174 | } 175 | } 176 | 177 | class BPP implements BeanPostProcessor { 178 | 179 | @Override 180 | public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { 181 | System.out.println("bean [" + bean + "] beanName [" + beanName + "]"); 182 | return bean; 183 | } 184 | } 185 | 186 | @Component 187 | class Foo { 188 | } 189 | 190 | @ConfigurationProperties(prefix = "bootiful") 191 | record BootifulProperties(String name) { 192 | } 193 | 194 | class Bar { 195 | 196 | private final Foo foo; 197 | 198 | Bar(Foo foo) { 199 | this.foo = foo; 200 | Assert.notNull(this.foo, "there should be a foo dependency"); 201 | System.out.println("got a foo"); 202 | } 203 | } -------------------------------------------------------------------------------- /ai/mvnw.cmd: -------------------------------------------------------------------------------- 1 | <# : batch portion 2 | @REM ---------------------------------------------------------------------------- 3 | @REM Licensed to the Apache Software Foundation (ASF) under one 4 | @REM or more contributor license agreements. See the NOTICE file 5 | @REM distributed with this work for additional information 6 | @REM regarding copyright ownership. The ASF licenses this file 7 | @REM to you under the Apache License, Version 2.0 (the 8 | @REM "License"); you may not use this file except in compliance 9 | @REM with the License. You may obtain a copy of the License at 10 | @REM 11 | @REM http://www.apache.org/licenses/LICENSE-2.0 12 | @REM 13 | @REM Unless required by applicable law or agreed to in writing, 14 | @REM software distributed under the License is distributed on an 15 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | @REM KIND, either express or implied. See the License for the 17 | @REM specific language governing permissions and limitations 18 | @REM under the License. 19 | @REM ---------------------------------------------------------------------------- 20 | 21 | @REM ---------------------------------------------------------------------------- 22 | @REM Apache Maven Wrapper startup batch script, version 3.3.2 23 | @REM 24 | @REM Optional ENV vars 25 | @REM MVNW_REPOURL - repo url base for downloading maven distribution 26 | @REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 27 | @REM MVNW_VERBOSE - true: enable verbose log; others: silence the output 28 | @REM ---------------------------------------------------------------------------- 29 | 30 | @IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) 31 | @SET __MVNW_CMD__= 32 | @SET __MVNW_ERROR__= 33 | @SET __MVNW_PSMODULEP_SAVE=%PSModulePath% 34 | @SET PSModulePath= 35 | @FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( 36 | IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) 37 | ) 38 | @SET PSModulePath=%__MVNW_PSMODULEP_SAVE% 39 | @SET __MVNW_PSMODULEP_SAVE= 40 | @SET __MVNW_ARG0_NAME__= 41 | @SET MVNW_USERNAME= 42 | @SET MVNW_PASSWORD= 43 | @IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) 44 | @echo Cannot start maven from wrapper >&2 && exit /b 1 45 | @GOTO :EOF 46 | : end batch / begin powershell #> 47 | 48 | $ErrorActionPreference = "Stop" 49 | if ($env:MVNW_VERBOSE -eq "true") { 50 | $VerbosePreference = "Continue" 51 | } 52 | 53 | # calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties 54 | $distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl 55 | if (!$distributionUrl) { 56 | Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" 57 | } 58 | 59 | switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { 60 | "maven-mvnd-*" { 61 | $USE_MVND = $true 62 | $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" 63 | $MVN_CMD = "mvnd.cmd" 64 | break 65 | } 66 | default { 67 | $USE_MVND = $false 68 | $MVN_CMD = $script -replace '^mvnw','mvn' 69 | break 70 | } 71 | } 72 | 73 | # apply MVNW_REPOURL and calculate MAVEN_HOME 74 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 75 | if ($env:MVNW_REPOURL) { 76 | $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } 77 | $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" 78 | } 79 | $distributionUrlName = $distributionUrl -replace '^.*/','' 80 | $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' 81 | $MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" 82 | if ($env:MAVEN_USER_HOME) { 83 | $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" 84 | } 85 | $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' 86 | $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" 87 | 88 | if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { 89 | Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" 90 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 91 | exit $? 92 | } 93 | 94 | if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { 95 | Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" 96 | } 97 | 98 | # prepare tmp dir 99 | $TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile 100 | $TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" 101 | $TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null 102 | trap { 103 | if ($TMP_DOWNLOAD_DIR.Exists) { 104 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 105 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 106 | } 107 | } 108 | 109 | New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null 110 | 111 | # Download and Install Apache Maven 112 | Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 113 | Write-Verbose "Downloading from: $distributionUrl" 114 | Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 115 | 116 | $webclient = New-Object System.Net.WebClient 117 | if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { 118 | $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) 119 | } 120 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 121 | $webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null 122 | 123 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 124 | $distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum 125 | if ($distributionSha256Sum) { 126 | if ($USE_MVND) { 127 | Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." 128 | } 129 | Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash 130 | if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { 131 | Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." 132 | } 133 | } 134 | 135 | # unzip and move 136 | Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null 137 | Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null 138 | try { 139 | Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null 140 | } catch { 141 | if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { 142 | Write-Error "fail to move MAVEN_HOME" 143 | } 144 | } finally { 145 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 146 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 147 | } 148 | 149 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 150 | -------------------------------------------------------------------------------- /aot/mvnw.cmd: -------------------------------------------------------------------------------- 1 | <# : batch portion 2 | @REM ---------------------------------------------------------------------------- 3 | @REM Licensed to the Apache Software Foundation (ASF) under one 4 | @REM or more contributor license agreements. See the NOTICE file 5 | @REM distributed with this work for additional information 6 | @REM regarding copyright ownership. The ASF licenses this file 7 | @REM to you under the Apache License, Version 2.0 (the 8 | @REM "License"); you may not use this file except in compliance 9 | @REM with the License. You may obtain a copy of the License at 10 | @REM 11 | @REM http://www.apache.org/licenses/LICENSE-2.0 12 | @REM 13 | @REM Unless required by applicable law or agreed to in writing, 14 | @REM software distributed under the License is distributed on an 15 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | @REM KIND, either express or implied. See the License for the 17 | @REM specific language governing permissions and limitations 18 | @REM under the License. 19 | @REM ---------------------------------------------------------------------------- 20 | 21 | @REM ---------------------------------------------------------------------------- 22 | @REM Apache Maven Wrapper startup batch script, version 3.3.2 23 | @REM 24 | @REM Optional ENV vars 25 | @REM MVNW_REPOURL - repo url base for downloading maven distribution 26 | @REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 27 | @REM MVNW_VERBOSE - true: enable verbose log; others: silence the output 28 | @REM ---------------------------------------------------------------------------- 29 | 30 | @IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) 31 | @SET __MVNW_CMD__= 32 | @SET __MVNW_ERROR__= 33 | @SET __MVNW_PSMODULEP_SAVE=%PSModulePath% 34 | @SET PSModulePath= 35 | @FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( 36 | IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) 37 | ) 38 | @SET PSModulePath=%__MVNW_PSMODULEP_SAVE% 39 | @SET __MVNW_PSMODULEP_SAVE= 40 | @SET __MVNW_ARG0_NAME__= 41 | @SET MVNW_USERNAME= 42 | @SET MVNW_PASSWORD= 43 | @IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) 44 | @echo Cannot start maven from wrapper >&2 && exit /b 1 45 | @GOTO :EOF 46 | : end batch / begin powershell #> 47 | 48 | $ErrorActionPreference = "Stop" 49 | if ($env:MVNW_VERBOSE -eq "true") { 50 | $VerbosePreference = "Continue" 51 | } 52 | 53 | # calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties 54 | $distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl 55 | if (!$distributionUrl) { 56 | Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" 57 | } 58 | 59 | switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { 60 | "maven-mvnd-*" { 61 | $USE_MVND = $true 62 | $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" 63 | $MVN_CMD = "mvnd.cmd" 64 | break 65 | } 66 | default { 67 | $USE_MVND = $false 68 | $MVN_CMD = $script -replace '^mvnw','mvn' 69 | break 70 | } 71 | } 72 | 73 | # apply MVNW_REPOURL and calculate MAVEN_HOME 74 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 75 | if ($env:MVNW_REPOURL) { 76 | $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } 77 | $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" 78 | } 79 | $distributionUrlName = $distributionUrl -replace '^.*/','' 80 | $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' 81 | $MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" 82 | if ($env:MAVEN_USER_HOME) { 83 | $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" 84 | } 85 | $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' 86 | $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" 87 | 88 | if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { 89 | Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" 90 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 91 | exit $? 92 | } 93 | 94 | if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { 95 | Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" 96 | } 97 | 98 | # prepare tmp dir 99 | $TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile 100 | $TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" 101 | $TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null 102 | trap { 103 | if ($TMP_DOWNLOAD_DIR.Exists) { 104 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 105 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 106 | } 107 | } 108 | 109 | New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null 110 | 111 | # Download and Install Apache Maven 112 | Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 113 | Write-Verbose "Downloading from: $distributionUrl" 114 | Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 115 | 116 | $webclient = New-Object System.Net.WebClient 117 | if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { 118 | $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) 119 | } 120 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 121 | $webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null 122 | 123 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 124 | $distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum 125 | if ($distributionSha256Sum) { 126 | if ($USE_MVND) { 127 | Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." 128 | } 129 | Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash 130 | if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { 131 | Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." 132 | } 133 | } 134 | 135 | # unzip and move 136 | Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null 137 | Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null 138 | try { 139 | Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null 140 | } catch { 141 | if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { 142 | Write-Error "fail to move MAVEN_HOME" 143 | } 144 | } finally { 145 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 146 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 147 | } 148 | 149 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 150 | -------------------------------------------------------------------------------- /basics/mvnw.cmd: -------------------------------------------------------------------------------- 1 | <# : batch portion 2 | @REM ---------------------------------------------------------------------------- 3 | @REM Licensed to the Apache Software Foundation (ASF) under one 4 | @REM or more contributor license agreements. See the NOTICE file 5 | @REM distributed with this work for additional information 6 | @REM regarding copyright ownership. The ASF licenses this file 7 | @REM to you under the Apache License, Version 2.0 (the 8 | @REM "License"); you may not use this file except in compliance 9 | @REM with the License. You may obtain a copy of the License at 10 | @REM 11 | @REM http://www.apache.org/licenses/LICENSE-2.0 12 | @REM 13 | @REM Unless required by applicable law or agreed to in writing, 14 | @REM software distributed under the License is distributed on an 15 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | @REM KIND, either express or implied. See the License for the 17 | @REM specific language governing permissions and limitations 18 | @REM under the License. 19 | @REM ---------------------------------------------------------------------------- 20 | 21 | @REM ---------------------------------------------------------------------------- 22 | @REM Apache Maven Wrapper startup batch script, version 3.3.2 23 | @REM 24 | @REM Optional ENV vars 25 | @REM MVNW_REPOURL - repo url base for downloading maven distribution 26 | @REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 27 | @REM MVNW_VERBOSE - true: enable verbose log; others: silence the output 28 | @REM ---------------------------------------------------------------------------- 29 | 30 | @IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) 31 | @SET __MVNW_CMD__= 32 | @SET __MVNW_ERROR__= 33 | @SET __MVNW_PSMODULEP_SAVE=%PSModulePath% 34 | @SET PSModulePath= 35 | @FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( 36 | IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) 37 | ) 38 | @SET PSModulePath=%__MVNW_PSMODULEP_SAVE% 39 | @SET __MVNW_PSMODULEP_SAVE= 40 | @SET __MVNW_ARG0_NAME__= 41 | @SET MVNW_USERNAME= 42 | @SET MVNW_PASSWORD= 43 | @IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) 44 | @echo Cannot start maven from wrapper >&2 && exit /b 1 45 | @GOTO :EOF 46 | : end batch / begin powershell #> 47 | 48 | $ErrorActionPreference = "Stop" 49 | if ($env:MVNW_VERBOSE -eq "true") { 50 | $VerbosePreference = "Continue" 51 | } 52 | 53 | # calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties 54 | $distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl 55 | if (!$distributionUrl) { 56 | Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" 57 | } 58 | 59 | switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { 60 | "maven-mvnd-*" { 61 | $USE_MVND = $true 62 | $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" 63 | $MVN_CMD = "mvnd.cmd" 64 | break 65 | } 66 | default { 67 | $USE_MVND = $false 68 | $MVN_CMD = $script -replace '^mvnw','mvn' 69 | break 70 | } 71 | } 72 | 73 | # apply MVNW_REPOURL and calculate MAVEN_HOME 74 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 75 | if ($env:MVNW_REPOURL) { 76 | $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } 77 | $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" 78 | } 79 | $distributionUrlName = $distributionUrl -replace '^.*/','' 80 | $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' 81 | $MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" 82 | if ($env:MAVEN_USER_HOME) { 83 | $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" 84 | } 85 | $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' 86 | $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" 87 | 88 | if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { 89 | Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" 90 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 91 | exit $? 92 | } 93 | 94 | if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { 95 | Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" 96 | } 97 | 98 | # prepare tmp dir 99 | $TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile 100 | $TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" 101 | $TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null 102 | trap { 103 | if ($TMP_DOWNLOAD_DIR.Exists) { 104 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 105 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 106 | } 107 | } 108 | 109 | New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null 110 | 111 | # Download and Install Apache Maven 112 | Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 113 | Write-Verbose "Downloading from: $distributionUrl" 114 | Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 115 | 116 | $webclient = New-Object System.Net.WebClient 117 | if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { 118 | $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) 119 | } 120 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 121 | $webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null 122 | 123 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 124 | $distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum 125 | if ($distributionSha256Sum) { 126 | if ($USE_MVND) { 127 | Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." 128 | } 129 | Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash 130 | if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { 131 | Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." 132 | } 133 | } 134 | 135 | # unzip and move 136 | Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null 137 | Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null 138 | try { 139 | Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null 140 | } catch { 141 | if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { 142 | Write-Error "fail to move MAVEN_HOME" 143 | } 144 | } finally { 145 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 146 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 147 | } 148 | 149 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 150 | -------------------------------------------------------------------------------- /batch/mvnw.cmd: -------------------------------------------------------------------------------- 1 | <# : batch portion 2 | @REM ---------------------------------------------------------------------------- 3 | @REM Licensed to the Apache Software Foundation (ASF) under one 4 | @REM or more contributor license agreements. See the NOTICE file 5 | @REM distributed with this work for additional information 6 | @REM regarding copyright ownership. The ASF licenses this file 7 | @REM to you under the Apache License, Version 2.0 (the 8 | @REM "License"); you may not use this file except in compliance 9 | @REM with the License. You may obtain a copy of the License at 10 | @REM 11 | @REM http://www.apache.org/licenses/LICENSE-2.0 12 | @REM 13 | @REM Unless required by applicable law or agreed to in writing, 14 | @REM software distributed under the License is distributed on an 15 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | @REM KIND, either express or implied. See the License for the 17 | @REM specific language governing permissions and limitations 18 | @REM under the License. 19 | @REM ---------------------------------------------------------------------------- 20 | 21 | @REM ---------------------------------------------------------------------------- 22 | @REM Apache Maven Wrapper startup batch script, version 3.3.2 23 | @REM 24 | @REM Optional ENV vars 25 | @REM MVNW_REPOURL - repo url base for downloading maven distribution 26 | @REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 27 | @REM MVNW_VERBOSE - true: enable verbose log; others: silence the output 28 | @REM ---------------------------------------------------------------------------- 29 | 30 | @IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) 31 | @SET __MVNW_CMD__= 32 | @SET __MVNW_ERROR__= 33 | @SET __MVNW_PSMODULEP_SAVE=%PSModulePath% 34 | @SET PSModulePath= 35 | @FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( 36 | IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) 37 | ) 38 | @SET PSModulePath=%__MVNW_PSMODULEP_SAVE% 39 | @SET __MVNW_PSMODULEP_SAVE= 40 | @SET __MVNW_ARG0_NAME__= 41 | @SET MVNW_USERNAME= 42 | @SET MVNW_PASSWORD= 43 | @IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) 44 | @echo Cannot start maven from wrapper >&2 && exit /b 1 45 | @GOTO :EOF 46 | : end batch / begin powershell #> 47 | 48 | $ErrorActionPreference = "Stop" 49 | if ($env:MVNW_VERBOSE -eq "true") { 50 | $VerbosePreference = "Continue" 51 | } 52 | 53 | # calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties 54 | $distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl 55 | if (!$distributionUrl) { 56 | Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" 57 | } 58 | 59 | switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { 60 | "maven-mvnd-*" { 61 | $USE_MVND = $true 62 | $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" 63 | $MVN_CMD = "mvnd.cmd" 64 | break 65 | } 66 | default { 67 | $USE_MVND = $false 68 | $MVN_CMD = $script -replace '^mvnw','mvn' 69 | break 70 | } 71 | } 72 | 73 | # apply MVNW_REPOURL and calculate MAVEN_HOME 74 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 75 | if ($env:MVNW_REPOURL) { 76 | $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } 77 | $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" 78 | } 79 | $distributionUrlName = $distributionUrl -replace '^.*/','' 80 | $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' 81 | $MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" 82 | if ($env:MAVEN_USER_HOME) { 83 | $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" 84 | } 85 | $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' 86 | $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" 87 | 88 | if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { 89 | Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" 90 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 91 | exit $? 92 | } 93 | 94 | if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { 95 | Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" 96 | } 97 | 98 | # prepare tmp dir 99 | $TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile 100 | $TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" 101 | $TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null 102 | trap { 103 | if ($TMP_DOWNLOAD_DIR.Exists) { 104 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 105 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 106 | } 107 | } 108 | 109 | New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null 110 | 111 | # Download and Install Apache Maven 112 | Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 113 | Write-Verbose "Downloading from: $distributionUrl" 114 | Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 115 | 116 | $webclient = New-Object System.Net.WebClient 117 | if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { 118 | $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) 119 | } 120 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 121 | $webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null 122 | 123 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 124 | $distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum 125 | if ($distributionSha256Sum) { 126 | if ($USE_MVND) { 127 | Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." 128 | } 129 | Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash 130 | if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { 131 | Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." 132 | } 133 | } 134 | 135 | # unzip and move 136 | Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null 137 | Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null 138 | try { 139 | Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null 140 | } catch { 141 | if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { 142 | Write-Error "fail to move MAVEN_HOME" 143 | } 144 | } finally { 145 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 146 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 147 | } 148 | 149 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 150 | -------------------------------------------------------------------------------- /beans/mvnw.cmd: -------------------------------------------------------------------------------- 1 | <# : batch portion 2 | @REM ---------------------------------------------------------------------------- 3 | @REM Licensed to the Apache Software Foundation (ASF) under one 4 | @REM or more contributor license agreements. See the NOTICE file 5 | @REM distributed with this work for additional information 6 | @REM regarding copyright ownership. The ASF licenses this file 7 | @REM to you under the Apache License, Version 2.0 (the 8 | @REM "License"); you may not use this file except in compliance 9 | @REM with the License. You may obtain a copy of the License at 10 | @REM 11 | @REM http://www.apache.org/licenses/LICENSE-2.0 12 | @REM 13 | @REM Unless required by applicable law or agreed to in writing, 14 | @REM software distributed under the License is distributed on an 15 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | @REM KIND, either express or implied. See the License for the 17 | @REM specific language governing permissions and limitations 18 | @REM under the License. 19 | @REM ---------------------------------------------------------------------------- 20 | 21 | @REM ---------------------------------------------------------------------------- 22 | @REM Apache Maven Wrapper startup batch script, version 3.3.2 23 | @REM 24 | @REM Optional ENV vars 25 | @REM MVNW_REPOURL - repo url base for downloading maven distribution 26 | @REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 27 | @REM MVNW_VERBOSE - true: enable verbose log; others: silence the output 28 | @REM ---------------------------------------------------------------------------- 29 | 30 | @IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) 31 | @SET __MVNW_CMD__= 32 | @SET __MVNW_ERROR__= 33 | @SET __MVNW_PSMODULEP_SAVE=%PSModulePath% 34 | @SET PSModulePath= 35 | @FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( 36 | IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) 37 | ) 38 | @SET PSModulePath=%__MVNW_PSMODULEP_SAVE% 39 | @SET __MVNW_PSMODULEP_SAVE= 40 | @SET __MVNW_ARG0_NAME__= 41 | @SET MVNW_USERNAME= 42 | @SET MVNW_PASSWORD= 43 | @IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) 44 | @echo Cannot start maven from wrapper >&2 && exit /b 1 45 | @GOTO :EOF 46 | : end batch / begin powershell #> 47 | 48 | $ErrorActionPreference = "Stop" 49 | if ($env:MVNW_VERBOSE -eq "true") { 50 | $VerbosePreference = "Continue" 51 | } 52 | 53 | # calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties 54 | $distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl 55 | if (!$distributionUrl) { 56 | Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" 57 | } 58 | 59 | switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { 60 | "maven-mvnd-*" { 61 | $USE_MVND = $true 62 | $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" 63 | $MVN_CMD = "mvnd.cmd" 64 | break 65 | } 66 | default { 67 | $USE_MVND = $false 68 | $MVN_CMD = $script -replace '^mvnw','mvn' 69 | break 70 | } 71 | } 72 | 73 | # apply MVNW_REPOURL and calculate MAVEN_HOME 74 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 75 | if ($env:MVNW_REPOURL) { 76 | $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } 77 | $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" 78 | } 79 | $distributionUrlName = $distributionUrl -replace '^.*/','' 80 | $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' 81 | $MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" 82 | if ($env:MAVEN_USER_HOME) { 83 | $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" 84 | } 85 | $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' 86 | $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" 87 | 88 | if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { 89 | Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" 90 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 91 | exit $? 92 | } 93 | 94 | if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { 95 | Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" 96 | } 97 | 98 | # prepare tmp dir 99 | $TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile 100 | $TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" 101 | $TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null 102 | trap { 103 | if ($TMP_DOWNLOAD_DIR.Exists) { 104 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 105 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 106 | } 107 | } 108 | 109 | New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null 110 | 111 | # Download and Install Apache Maven 112 | Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 113 | Write-Verbose "Downloading from: $distributionUrl" 114 | Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 115 | 116 | $webclient = New-Object System.Net.WebClient 117 | if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { 118 | $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) 119 | } 120 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 121 | $webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null 122 | 123 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 124 | $distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum 125 | if ($distributionSha256Sum) { 126 | if ($USE_MVND) { 127 | Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." 128 | } 129 | Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash 130 | if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { 131 | Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." 132 | } 133 | } 134 | 135 | # unzip and move 136 | Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null 137 | Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null 138 | try { 139 | Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null 140 | } catch { 141 | if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { 142 | Write-Error "fail to move MAVEN_HOME" 143 | } 144 | } finally { 145 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 146 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 147 | } 148 | 149 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 150 | -------------------------------------------------------------------------------- /data/mvnw.cmd: -------------------------------------------------------------------------------- 1 | <# : batch portion 2 | @REM ---------------------------------------------------------------------------- 3 | @REM Licensed to the Apache Software Foundation (ASF) under one 4 | @REM or more contributor license agreements. See the NOTICE file 5 | @REM distributed with this work for additional information 6 | @REM regarding copyright ownership. The ASF licenses this file 7 | @REM to you under the Apache License, Version 2.0 (the 8 | @REM "License"); you may not use this file except in compliance 9 | @REM with the License. You may obtain a copy of the License at 10 | @REM 11 | @REM http://www.apache.org/licenses/LICENSE-2.0 12 | @REM 13 | @REM Unless required by applicable law or agreed to in writing, 14 | @REM software distributed under the License is distributed on an 15 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | @REM KIND, either express or implied. See the License for the 17 | @REM specific language governing permissions and limitations 18 | @REM under the License. 19 | @REM ---------------------------------------------------------------------------- 20 | 21 | @REM ---------------------------------------------------------------------------- 22 | @REM Apache Maven Wrapper startup batch script, version 3.3.2 23 | @REM 24 | @REM Optional ENV vars 25 | @REM MVNW_REPOURL - repo url base for downloading maven distribution 26 | @REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 27 | @REM MVNW_VERBOSE - true: enable verbose log; others: silence the output 28 | @REM ---------------------------------------------------------------------------- 29 | 30 | @IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) 31 | @SET __MVNW_CMD__= 32 | @SET __MVNW_ERROR__= 33 | @SET __MVNW_PSMODULEP_SAVE=%PSModulePath% 34 | @SET PSModulePath= 35 | @FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( 36 | IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) 37 | ) 38 | @SET PSModulePath=%__MVNW_PSMODULEP_SAVE% 39 | @SET __MVNW_PSMODULEP_SAVE= 40 | @SET __MVNW_ARG0_NAME__= 41 | @SET MVNW_USERNAME= 42 | @SET MVNW_PASSWORD= 43 | @IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) 44 | @echo Cannot start maven from wrapper >&2 && exit /b 1 45 | @GOTO :EOF 46 | : end batch / begin powershell #> 47 | 48 | $ErrorActionPreference = "Stop" 49 | if ($env:MVNW_VERBOSE -eq "true") { 50 | $VerbosePreference = "Continue" 51 | } 52 | 53 | # calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties 54 | $distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl 55 | if (!$distributionUrl) { 56 | Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" 57 | } 58 | 59 | switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { 60 | "maven-mvnd-*" { 61 | $USE_MVND = $true 62 | $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" 63 | $MVN_CMD = "mvnd.cmd" 64 | break 65 | } 66 | default { 67 | $USE_MVND = $false 68 | $MVN_CMD = $script -replace '^mvnw','mvn' 69 | break 70 | } 71 | } 72 | 73 | # apply MVNW_REPOURL and calculate MAVEN_HOME 74 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 75 | if ($env:MVNW_REPOURL) { 76 | $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } 77 | $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" 78 | } 79 | $distributionUrlName = $distributionUrl -replace '^.*/','' 80 | $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' 81 | $MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" 82 | if ($env:MAVEN_USER_HOME) { 83 | $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" 84 | } 85 | $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' 86 | $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" 87 | 88 | if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { 89 | Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" 90 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 91 | exit $? 92 | } 93 | 94 | if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { 95 | Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" 96 | } 97 | 98 | # prepare tmp dir 99 | $TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile 100 | $TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" 101 | $TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null 102 | trap { 103 | if ($TMP_DOWNLOAD_DIR.Exists) { 104 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 105 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 106 | } 107 | } 108 | 109 | New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null 110 | 111 | # Download and Install Apache Maven 112 | Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 113 | Write-Verbose "Downloading from: $distributionUrl" 114 | Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 115 | 116 | $webclient = New-Object System.Net.WebClient 117 | if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { 118 | $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) 119 | } 120 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 121 | $webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null 122 | 123 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 124 | $distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum 125 | if ($distributionSha256Sum) { 126 | if ($USE_MVND) { 127 | Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." 128 | } 129 | Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash 130 | if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { 131 | Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." 132 | } 133 | } 134 | 135 | # unzip and move 136 | Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null 137 | Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null 138 | try { 139 | Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null 140 | } catch { 141 | if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { 142 | Write-Error "fail to move MAVEN_HOME" 143 | } 144 | } finally { 145 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 146 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 147 | } 148 | 149 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 150 | -------------------------------------------------------------------------------- /web/mvnw.cmd: -------------------------------------------------------------------------------- 1 | <# : batch portion 2 | @REM ---------------------------------------------------------------------------- 3 | @REM Licensed to the Apache Software Foundation (ASF) under one 4 | @REM or more contributor license agreements. See the NOTICE file 5 | @REM distributed with this work for additional information 6 | @REM regarding copyright ownership. The ASF licenses this file 7 | @REM to you under the Apache License, Version 2.0 (the 8 | @REM "License"); you may not use this file except in compliance 9 | @REM with the License. You may obtain a copy of the License at 10 | @REM 11 | @REM http://www.apache.org/licenses/LICENSE-2.0 12 | @REM 13 | @REM Unless required by applicable law or agreed to in writing, 14 | @REM software distributed under the License is distributed on an 15 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | @REM KIND, either express or implied. See the License for the 17 | @REM specific language governing permissions and limitations 18 | @REM under the License. 19 | @REM ---------------------------------------------------------------------------- 20 | 21 | @REM ---------------------------------------------------------------------------- 22 | @REM Apache Maven Wrapper startup batch script, version 3.3.2 23 | @REM 24 | @REM Optional ENV vars 25 | @REM MVNW_REPOURL - repo url base for downloading maven distribution 26 | @REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 27 | @REM MVNW_VERBOSE - true: enable verbose log; others: silence the output 28 | @REM ---------------------------------------------------------------------------- 29 | 30 | @IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) 31 | @SET __MVNW_CMD__= 32 | @SET __MVNW_ERROR__= 33 | @SET __MVNW_PSMODULEP_SAVE=%PSModulePath% 34 | @SET PSModulePath= 35 | @FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( 36 | IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) 37 | ) 38 | @SET PSModulePath=%__MVNW_PSMODULEP_SAVE% 39 | @SET __MVNW_PSMODULEP_SAVE= 40 | @SET __MVNW_ARG0_NAME__= 41 | @SET MVNW_USERNAME= 42 | @SET MVNW_PASSWORD= 43 | @IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) 44 | @echo Cannot start maven from wrapper >&2 && exit /b 1 45 | @GOTO :EOF 46 | : end batch / begin powershell #> 47 | 48 | $ErrorActionPreference = "Stop" 49 | if ($env:MVNW_VERBOSE -eq "true") { 50 | $VerbosePreference = "Continue" 51 | } 52 | 53 | # calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties 54 | $distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl 55 | if (!$distributionUrl) { 56 | Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" 57 | } 58 | 59 | switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { 60 | "maven-mvnd-*" { 61 | $USE_MVND = $true 62 | $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" 63 | $MVN_CMD = "mvnd.cmd" 64 | break 65 | } 66 | default { 67 | $USE_MVND = $false 68 | $MVN_CMD = $script -replace '^mvnw','mvn' 69 | break 70 | } 71 | } 72 | 73 | # apply MVNW_REPOURL and calculate MAVEN_HOME 74 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 75 | if ($env:MVNW_REPOURL) { 76 | $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } 77 | $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" 78 | } 79 | $distributionUrlName = $distributionUrl -replace '^.*/','' 80 | $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' 81 | $MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" 82 | if ($env:MAVEN_USER_HOME) { 83 | $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" 84 | } 85 | $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' 86 | $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" 87 | 88 | if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { 89 | Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" 90 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 91 | exit $? 92 | } 93 | 94 | if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { 95 | Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" 96 | } 97 | 98 | # prepare tmp dir 99 | $TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile 100 | $TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" 101 | $TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null 102 | trap { 103 | if ($TMP_DOWNLOAD_DIR.Exists) { 104 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 105 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 106 | } 107 | } 108 | 109 | New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null 110 | 111 | # Download and Install Apache Maven 112 | Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 113 | Write-Verbose "Downloading from: $distributionUrl" 114 | Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 115 | 116 | $webclient = New-Object System.Net.WebClient 117 | if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { 118 | $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) 119 | } 120 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 121 | $webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null 122 | 123 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 124 | $distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum 125 | if ($distributionSha256Sum) { 126 | if ($USE_MVND) { 127 | Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." 128 | } 129 | Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash 130 | if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { 131 | Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." 132 | } 133 | } 134 | 135 | # unzip and move 136 | Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null 137 | Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null 138 | try { 139 | Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null 140 | } catch { 141 | if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { 142 | Write-Error "fail to move MAVEN_HOME" 143 | } 144 | } finally { 145 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 146 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 147 | } 148 | 149 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 150 | --------------------------------------------------------------------------------