├── RESTful-web-service-sts ├── .classpath ├── .project ├── mvnw ├── mvnw.cmd ├── pom.xml ├── sql.txt └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── mcnz │ │ │ └── restful │ │ │ └── spring │ │ │ └── boot │ │ │ ├── RestfulSpringExampleApplication.java │ │ │ ├── Score.java │ │ │ └── ScoreService.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── mcnz │ └── restful │ └── spring │ └── boot │ └── RestfulSpringExampleApplicationTests.java ├── SpringSoapExample ├── HELP.md ├── mvnw.cmd ├── pom.xml ├── readme.md └── src │ ├── main │ ├── java │ │ ├── META-INF │ │ │ └── JAXB │ │ │ │ └── episode_xjc.xjb │ │ └── com │ │ │ └── mcnz │ │ │ ├── jee │ │ │ └── soap │ │ │ │ ├── GetScoreRequest.java │ │ │ │ ├── GetScoreResponse.java │ │ │ │ ├── ObjectFactory.java │ │ │ │ ├── Score.java │ │ │ │ └── package-info.java │ │ │ └── spring │ │ │ └── soap │ │ │ ├── ScoreEndpoint.java │ │ │ ├── SpringWithSoapApplication.java │ │ │ └── WebServiceConfiguration.java │ └── resources │ │ ├── application.properties │ │ └── score.xsd │ └── test │ └── java │ └── com │ └── mcnz │ └── spring │ └── soap │ └── SpringWithSoapApplicationTests.java ├── WA3104-REL_1_1-LabGuide.pdf ├── commands.txt ├── comprehensive-rps ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── mcnz │ │ └── rps │ │ └── spring │ │ ├── GameSummary.java │ │ ├── GameSummaryRepository.java │ │ ├── GameSummaryService.java │ │ ├── Gesture.java │ │ ├── RoshamboApplication.java │ │ ├── Score.java │ │ ├── ScoreRepository.java │ │ ├── ScoreService.java │ │ └── WebController.java │ └── resources │ ├── META-INF │ └── xxxpersistence.xmlxxx │ ├── application.properties │ └── templates │ ├── index.html │ └── results.html ├── labs ├── Lab 06 - Utilizing Runners, Arguments, and Environment.zip ├── Lab 07 - Using Multiple ViewResolver.zip ├── Lab 08 - Implementing Spring Data REST.zip ├── Lab 09 - Implementing OAuth2 using Spring Boot.zip ├── Lab 11 - Authentication with JWT.zip ├── Lab 12 - Spring Boot Actuator.zip ├── LabGuide-Protected.pdf ├── Restaurant-Microservice.zip ├── Spring-Boot-AMQP-Starter.zip ├── Spring-Boot-Basic-Security-Starter.zip ├── Spring-Boot-JDBC-Starter.zip ├── Spring-Boot-MVC-Starter.zip ├── Spring-Boot-REST-Client-Starter.zip ├── Spring-Boot-REST-Starter.zip ├── WA3104-REL_1_1-LabGuide.pdf ├── files.txt ├── labs 1-5.zip ├── spring-controllers-starter.zip └── spring-data-rest-starter.zip ├── settling-scores ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── mcnz │ │ │ └── rps │ │ │ ├── Score.java │ │ │ ├── ScoreController.java │ │ │ └── SettlingScoresApplication.java │ └── resources │ │ ├── application.properties │ │ └── static │ │ └── index.html │ └── test │ └── java │ └── com │ └── mcnz │ └── rps │ └── SettlingScoresApplicationTests.java ├── simple-spring-mvc-rps ├── .classpath ├── .project ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── mcnz │ │ │ └── rps │ │ │ └── smvc │ │ │ ├── SpringMvcRpsApplication.java │ │ │ └── WebController.java │ └── resources │ │ ├── application.properties │ │ └── templates │ │ ├── index.html │ │ └── results.html │ └── test │ └── java │ └── com │ └── mcnz │ └── rps │ └── smvc │ └── SpringMvcRpsApplicationTests.java ├── simple-spring-rest-keeping-score ├── .gitignore ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── mcnz │ │ │ └── rps │ │ │ └── rest │ │ │ ├── KeepingScoreApplication.java │ │ │ ├── Score.java │ │ │ ├── ScoreService.java │ │ │ └── ServletInitializer.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── mcnz │ └── rps │ └── rest │ └── KeepingScoreApplicationTests.java ├── spring-boot-file-upload ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── mcnz │ │ │ └── spring │ │ │ ├── SpringBootUploaderApplication.java │ │ │ └── SpringFileUploadController.java │ └── resources │ │ ├── application.properties │ │ └── templates │ │ └── uploader.html │ └── test │ └── java │ └── com │ └── mcnz │ └── spring │ └── SpringBootUploaderApplicationTests.java ├── spring-configuration-example ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── mcnz │ │ └── spring │ │ └── configuration │ │ ├── SpringBootConfiguration.java │ │ └── SpringConfigurationExampleApplication.java │ └── resources │ └── application.properties ├── spring-console-app ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── demo │ │ │ ├── ConsoleAppApplication.java │ │ │ ├── MyConsoleAppApplication.java │ │ │ ├── Score.java │ │ │ └── ScoreRepository.java │ └── resources │ │ ├── application.properties │ │ ├── data.sql │ │ └── schema.sql │ └── test │ └── java │ └── com │ └── example │ └── demo │ └── MyConsoleAppApplicationTests.java ├── spring-ioc-example ├── .classpath ├── .project ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── mcnz │ │ └── ioc │ │ └── example │ │ ├── GameService.java │ │ └── Score.java │ └── resources │ └── spring-context.xml ├── spring-mvc-rest-jpa ├── .gitignore ├── game.html ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── mcnz │ │ └── rps │ │ └── spring │ │ ├── GameSummary.java │ │ ├── GameSummaryRepository.java │ │ ├── GameSummaryService.java │ │ ├── Gesture.java │ │ ├── RoshamboApplication.java │ │ ├── Score.java │ │ ├── ScoreRepository.java │ │ ├── ScoreService.java │ │ └── WebController.java │ └── resources │ ├── META-INF │ └── xxxpersistence.xmlxxx │ ├── application.properties │ └── templates │ ├── index.html │ └── results.html ├── spring-mvc-spring-data-jdbc ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── mcnz │ │ │ └── rps │ │ │ ├── RoshamboApplication.java │ │ │ ├── Score.java │ │ │ ├── ScoreRepository.java │ │ │ └── WebController.java │ └── resources │ │ ├── application.properties │ │ ├── schema.sql │ │ ├── static │ │ └── index.html │ │ └── templates │ │ └── results.html │ └── test │ └── java │ └── com │ └── mcnz │ └── rps │ └── RoshamboApplicationTests.java └── spring-rest ├── .gitignore ├── .mvn └── wrapper │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── mcnz │ │ └── rps │ │ ├── GameSummary.java │ │ ├── GameSummaryController.java │ │ ├── RoshamboApplication.java │ │ ├── Score.java │ │ └── ScoreController.java └── resources │ ├── application.properties │ └── static │ └── index.html └── test └── java └── com └── mcnz └── rps └── RoshamboApplicationTests.java /RESTful-web-service-sts/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /RESTful-web-service-sts/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | restful-spring-example 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.common.project.facet.core.builder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.springframework.ide.eclipse.core.springbuilder 20 | 21 | 22 | 23 | 24 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 25 | 26 | 27 | 28 | 29 | org.eclipse.m2e.core.maven2Builder 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.ide.eclipse.core.springnature 36 | org.eclipse.jdt.core.javanature 37 | org.eclipse.m2e.core.maven2Nature 38 | org.eclipse.wst.common.project.facet.core.nature 39 | 40 | 41 | -------------------------------------------------------------------------------- /RESTful-web-service-sts/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /RESTful-web-service-sts/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.mcnz.restful.spring.boot 7 | spring-boot-tutorial 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | restful-spring-example 12 | Step by step spring boot example 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.3.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-devtools 36 | runtime 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 | 56 | -------------------------------------------------------------------------------- /RESTful-web-service-sts/sql.txt: -------------------------------------------------------------------------------- 1 | -- ---------------------------------------------- 2 | -- DDL Statements for tables 3 | -- ---------------------------------------------- 4 | 5 | CREATE TABLE SCORE ( 6 | id INTEGER auto_increment NOT NULL, 7 | wins INTEGER NOT NULL, 8 | losses INTEGER NOT NULL, 9 | ties INTEGER NOT NULL, 10 | PRIMARY KEY (id) 11 | ); 12 | 13 | 14 | CREATE TABLE GAMESUMMARY ( 15 | id INTEGER auto_increment NOT NULL, 16 | CLIENT VARCHAR(255) NOT NULL, 17 | SERVER VARCHAR(255) NOT NULL, 18 | RESULT VARCHAR(255) NOT NULL, 19 | PRIMARY KEY (id) 20 | ); 21 | -- ---------------------------------------------- 22 | -- DDL Statements for keys 23 | -- ---------------------------------------------- 24 | 25 | CREATE TABLE `roshambo`.`gamesummary` ( 26 | `id` INT NOT NULL AUTO_INCREMENT, 27 | `client` INT NOT NULL, 28 | `server` INT NOT NULL, 29 | `result` INT NOT NULL, 30 | PRIMARY KEY (`id`) 31 | ); 32 | 33 | CREATE TABLE roshambo.gamesummary ( 34 | id INTEGER auto_increment NOT NULL, 35 | client VARCHAR(255) NOT NULL, 36 | server VARCHAR(255) NOT NULL, 37 | result VARCHAR(255) NOT NULL, 38 | PRIMARY KEY (id) 39 | ); 40 | 41 | 42 | insert into roshambo.gamesummary (client, server, result) 43 | values("rock", "paper", "win"); 44 | -------------------------------------------------------------------------------- /RESTful-web-service-sts/src/main/java/com/mcnz/restful/spring/boot/RestfulSpringExampleApplication.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.restful.spring.boot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class RestfulSpringExampleApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(RestfulSpringExampleApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /RESTful-web-service-sts/src/main/java/com/mcnz/restful/spring/boot/Score.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.restful.spring.boot; 2 | 3 | public class Score { 4 | 5 | public static int WINS, LOSSES, TIES; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /RESTful-web-service-sts/src/main/java/com/mcnz/restful/spring/boot/ScoreService.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.restful.spring.boot; 2 | 3 | import org.springframework.http.MediaType; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | public class ScoreService { 10 | 11 | 12 | 13 | //{ "wins":"5", "losses":"3", "ties": "0"} 14 | @RequestMapping(value="/score", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) 15 | public String getScore() { 16 | String pattern = "{ \"wins\":\"%s\", \"losses\":\"%s\", \"ties\": \"%s\"}"; 17 | return String.format(pattern, Score.WINS, Score.LOSSES, Score.TIES ); 18 | 19 | } 20 | 21 | @RequestMapping(value="/score", method=RequestMethod.PUT, produces=MediaType.APPLICATION_JSON_VALUE) 22 | public String update(int wins, int losses, int ties) { 23 | Score.WINS = wins; 24 | Score.TIES = ties; 25 | Score.LOSSES = losses; 26 | String pattern = "{ \"wins\":\"%s\", \"losses\":\"%s\", \"ties\": \"%s\"}"; 27 | return String.format(pattern, Score.WINS, Score.LOSSES, Score.TIES ); 28 | } 29 | 30 | 31 | @RequestMapping(value="/score/wins", method=RequestMethod.POST) 32 | public int increaseWins() { 33 | Score.WINS++; 34 | return Score.WINS; 35 | } 36 | @RequestMapping(value="/score/losses", method=RequestMethod.POST) 37 | public int increaseLosses() { 38 | Score.LOSSES++; 39 | return Score.LOSSES; 40 | } 41 | @RequestMapping(value="/score/ties", method=RequestMethod.POST) 42 | public int increaseTies() { 43 | Score.TIES ++; 44 | return Score.TIES ; 45 | } 46 | 47 | @RequestMapping(value="/score/wins", method=RequestMethod.GET) 48 | public int getWins() { 49 | return Score.WINS; 50 | } 51 | @RequestMapping(value="/score/losses", method=RequestMethod.GET) 52 | public int getLosses() { 53 | return Score.LOSSES; 54 | } 55 | @RequestMapping(value="/score/ties", method=RequestMethod.GET) 56 | public int getTies() { 57 | return Score.TIES ; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /RESTful-web-service-sts/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/RESTful-web-service-sts/src/main/resources/application.properties -------------------------------------------------------------------------------- /RESTful-web-service-sts/src/test/java/com/mcnz/restful/spring/boot/RestfulSpringExampleApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.restful.spring.boot; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class RestfulSpringExampleApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /SpringSoapExample/HELP.md: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | 3 | ### Reference Documentation 4 | For further reference, please consider the following sections: 5 | 6 | * [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) 7 | * [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/3.3.4/maven-plugin) 8 | * [Create an OCI image](https://docs.spring.io/spring-boot/3.3.4/maven-plugin/build-image.html) 9 | * [Spring Boot DevTools](https://docs.spring.io/spring-boot/docs/3.3.4/reference/htmlsingle/index.html#using.devtools) 10 | * [Spring Web Services](https://docs.spring.io/spring-boot/docs/3.3.4/reference/htmlsingle/index.html#io.webservices) 11 | 12 | ### Guides 13 | The following guides illustrate how to use some features concretely: 14 | 15 | * [Producing a SOAP web service](https://spring.io/guides/gs/producing-web-service/) 16 | 17 | ### Maven Parent overrides 18 | 19 | Due to Maven's design, elements are inherited from the parent POM to the project POM. 20 | While most of the inheritance is fine, it also inherits unwanted elements like `` and `` from the parent. 21 | To prevent this, the project POM contains empty overrides for these elements. 22 | If you manually switch to a different parent and actually want the inheritance, you need to remove those overrides. 23 | 24 | -------------------------------------------------------------------------------- /SpringSoapExample/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 | -------------------------------------------------------------------------------- /SpringSoapExample/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 3.3.4 10 | 11 | 12 | com.mcnz.spring.soap 13 | SpringWithSoap 14 | 1.0 15 | SpringWithSoap 16 | Demo project for Spring Boot 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 17 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web-services 37 | 38 | 39 | 40 | wsdl4j 41 | wsdl4j 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-devtools 47 | runtime 48 | true 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-test 53 | test 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-maven-plugin 62 | 63 | 64 | 65 | org.codehaus.mojo 66 | jaxb2-maven-plugin 67 | 3.2.0 68 | 69 | 70 | xjc 71 | 72 | xjc 73 | 74 | 75 | 76 | 77 | 78 | src/main/resources/score.xsd 79 | 80 | src/main/java 81 | false 82 | 83 | 84 | 85 | org.springframework.boot 86 | spring-boot-maven-plugin 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /SpringSoapExample/readme.md: -------------------------------------------------------------------------------- 1 | Enjoy! 2 | -------------------------------------------------------------------------------- /SpringSoapExample/src/main/java/META-INF/JAXB/episode_xjc.xjb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /SpringSoapExample/src/main/java/com/mcnz/jee/soap/GetScoreRequest.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the Eclipse Implementation of JAXB, v3.0.2 3 | // See https://eclipse-ee4j.github.io/jaxb-ri 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2024.10.11 at 08:22:49 PM EDT 6 | // 7 | 8 | 9 | package com.mcnz.jee.soap; 10 | 11 | import jakarta.xml.bind.annotation.XmlAccessType; 12 | import jakarta.xml.bind.annotation.XmlAccessorType; 13 | import jakarta.xml.bind.annotation.XmlElement; 14 | import jakarta.xml.bind.annotation.XmlRootElement; 15 | import jakarta.xml.bind.annotation.XmlType; 16 | 17 | 18 | /** 19 | *

Java class for anonymous complex type. 20 | * 21 | *

The following schema fragment specifies the expected content contained within this class. 22 | * 23 | *

24 |  * <complexType>
25 |  *   <complexContent>
26 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
27 |  *       <sequence>
28 |  *         <element name="user" type="{http://www.w3.org/2001/XMLSchema}string"/>
29 |  *       </sequence>
30 |  *     </restriction>
31 |  *   </complexContent>
32 |  * </complexType>
33 |  * 
34 | * 35 | * 36 | */ 37 | @XmlAccessorType(XmlAccessType.FIELD) 38 | @XmlType(name = "", propOrder = { 39 | "user" 40 | }) 41 | @XmlRootElement(name = "getScoreRequest") 42 | public class GetScoreRequest { 43 | 44 | @XmlElement(required = true) 45 | protected String user; 46 | 47 | /** 48 | * Gets the value of the user property. 49 | * 50 | * @return 51 | * possible object is 52 | * {@link String } 53 | * 54 | */ 55 | public String getUser() { 56 | return user; 57 | } 58 | 59 | /** 60 | * Sets the value of the user property. 61 | * 62 | * @param value 63 | * allowed object is 64 | * {@link String } 65 | * 66 | */ 67 | public void setUser(String value) { 68 | this.user = value; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /SpringSoapExample/src/main/java/com/mcnz/jee/soap/GetScoreResponse.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the Eclipse Implementation of JAXB, v3.0.2 3 | // See https://eclipse-ee4j.github.io/jaxb-ri 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2024.10.11 at 08:22:49 PM EDT 6 | // 7 | 8 | 9 | package com.mcnz.jee.soap; 10 | 11 | import jakarta.xml.bind.annotation.XmlAccessType; 12 | import jakarta.xml.bind.annotation.XmlAccessorType; 13 | import jakarta.xml.bind.annotation.XmlElement; 14 | import jakarta.xml.bind.annotation.XmlRootElement; 15 | import jakarta.xml.bind.annotation.XmlType; 16 | 17 | 18 | /** 19 | *

Java class for anonymous complex type. 20 | * 21 | *

The following schema fragment specifies the expected content contained within this class. 22 | * 23 | *

24 |  * <complexType>
25 |  *   <complexContent>
26 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
27 |  *       <sequence>
28 |  *         <element name="score" type="{http://soap.jee.mcnz.com/}score"/>
29 |  *       </sequence>
30 |  *     </restriction>
31 |  *   </complexContent>
32 |  * </complexType>
33 |  * 
34 | * 35 | * 36 | */ 37 | @XmlAccessorType(XmlAccessType.FIELD) 38 | @XmlType(name = "", propOrder = { 39 | "score" 40 | }) 41 | @XmlRootElement(name = "getScoreResponse") 42 | public class GetScoreResponse { 43 | 44 | @XmlElement(required = true) 45 | protected Score score; 46 | 47 | /** 48 | * Gets the value of the score property. 49 | * 50 | * @return 51 | * possible object is 52 | * {@link Score } 53 | * 54 | */ 55 | public Score getScore() { 56 | return score; 57 | } 58 | 59 | /** 60 | * Sets the value of the score property. 61 | * 62 | * @param value 63 | * allowed object is 64 | * {@link Score } 65 | * 66 | */ 67 | public void setScore(Score value) { 68 | this.score = value; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /SpringSoapExample/src/main/java/com/mcnz/jee/soap/ObjectFactory.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the Eclipse Implementation of JAXB, v3.0.2 3 | // See https://eclipse-ee4j.github.io/jaxb-ri 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2024.10.11 at 08:22:49 PM EDT 6 | // 7 | 8 | 9 | package com.mcnz.jee.soap; 10 | 11 | import jakarta.xml.bind.annotation.XmlRegistry; 12 | 13 | 14 | /** 15 | * This object contains factory methods for each 16 | * Java content interface and Java element interface 17 | * generated in the com.mcnz.jee.soap package. 18 | *

An ObjectFactory allows you to programatically 19 | * construct new instances of the Java representation 20 | * for XML content. The Java representation of XML 21 | * content can consist of schema derived interfaces 22 | * and classes representing the binding of schema 23 | * type definitions, element declarations and model 24 | * groups. Factory methods for each of these are 25 | * provided in this class. 26 | * 27 | */ 28 | @XmlRegistry 29 | public class ObjectFactory { 30 | 31 | 32 | /** 33 | * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.mcnz.jee.soap 34 | * 35 | */ 36 | public ObjectFactory() { 37 | } 38 | 39 | /** 40 | * Create an instance of {@link GetScoreRequest } 41 | * 42 | */ 43 | public GetScoreRequest createGetScoreRequest() { 44 | return new GetScoreRequest(); 45 | } 46 | 47 | /** 48 | * Create an instance of {@link GetScoreResponse } 49 | * 50 | */ 51 | public GetScoreResponse createGetScoreResponse() { 52 | return new GetScoreResponse(); 53 | } 54 | 55 | /** 56 | * Create an instance of {@link Score } 57 | * 58 | */ 59 | public Score createScore() { 60 | return new Score(); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /SpringSoapExample/src/main/java/com/mcnz/jee/soap/Score.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the Eclipse Implementation of JAXB, v3.0.2 3 | // See https://eclipse-ee4j.github.io/jaxb-ri 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2024.10.11 at 08:22:49 PM EDT 6 | // 7 | 8 | 9 | package com.mcnz.jee.soap; 10 | 11 | import jakarta.xml.bind.annotation.XmlAccessType; 12 | import jakarta.xml.bind.annotation.XmlAccessorType; 13 | import jakarta.xml.bind.annotation.XmlElement; 14 | import jakarta.xml.bind.annotation.XmlType; 15 | 16 | 17 | /** 18 | *

Java class for score complex type. 19 | * 20 | *

The following schema fragment specifies the expected content contained within this class. 21 | * 22 | *

 23 |  * <complexType name="score">
 24 |  *   <complexContent>
 25 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 26 |  *       <sequence>
 27 |  *         <element name="user" type="{http://www.w3.org/2001/XMLSchema}string"/>
 28 |  *         <element name="wins" type="{http://www.w3.org/2001/XMLSchema}int"/>
 29 |  *         <element name="losses" type="{http://www.w3.org/2001/XMLSchema}int"/>
 30 |  *         <element name="ties" type="{http://www.w3.org/2001/XMLSchema}int"/>
 31 |  *       </sequence>
 32 |  *     </restriction>
 33 |  *   </complexContent>
 34 |  * </complexType>
 35 |  * 
36 | * 37 | * 38 | */ 39 | @XmlAccessorType(XmlAccessType.FIELD) 40 | @XmlType(name = "score", propOrder = { 41 | "user", 42 | "wins", 43 | "losses", 44 | "ties" 45 | }) 46 | public class Score { 47 | 48 | @XmlElement(required = true) 49 | protected String user; 50 | protected int wins; 51 | protected int losses; 52 | protected int ties; 53 | 54 | /** 55 | * Gets the value of the user property. 56 | * 57 | * @return 58 | * possible object is 59 | * {@link String } 60 | * 61 | */ 62 | public String getUser() { 63 | return user; 64 | } 65 | 66 | /** 67 | * Sets the value of the user property. 68 | * 69 | * @param value 70 | * allowed object is 71 | * {@link String } 72 | * 73 | */ 74 | public void setUser(String value) { 75 | this.user = value; 76 | } 77 | 78 | /** 79 | * Gets the value of the wins property. 80 | * 81 | */ 82 | public int getWins() { 83 | return wins; 84 | } 85 | 86 | /** 87 | * Sets the value of the wins property. 88 | * 89 | */ 90 | public void setWins(int value) { 91 | this.wins = value; 92 | } 93 | 94 | /** 95 | * Gets the value of the losses property. 96 | * 97 | */ 98 | public int getLosses() { 99 | return losses; 100 | } 101 | 102 | /** 103 | * Sets the value of the losses property. 104 | * 105 | */ 106 | public void setLosses(int value) { 107 | this.losses = value; 108 | } 109 | 110 | /** 111 | * Gets the value of the ties property. 112 | * 113 | */ 114 | public int getTies() { 115 | return ties; 116 | } 117 | 118 | /** 119 | * Sets the value of the ties property. 120 | * 121 | */ 122 | public void setTies(int value) { 123 | this.ties = value; 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /SpringSoapExample/src/main/java/com/mcnz/jee/soap/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the Eclipse Implementation of JAXB, v3.0.2 3 | // See https://eclipse-ee4j.github.io/jaxb-ri 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2024.10.11 at 08:22:49 PM EDT 6 | // 7 | 8 | @jakarta.xml.bind.annotation.XmlSchema(namespace = "http://soap.jee.mcnz.com/", elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED) 9 | package com.mcnz.jee.soap; 10 | -------------------------------------------------------------------------------- /SpringSoapExample/src/main/java/com/mcnz/spring/soap/ScoreEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.spring.soap; 2 | 3 | import org.springframework.ws.server.endpoint.annotation.Endpoint; 4 | import org.springframework.ws.server.endpoint.annotation.PayloadRoot; 5 | import org.springframework.ws.server.endpoint.annotation.RequestPayload; 6 | import org.springframework.ws.server.endpoint.annotation.ResponsePayload; 7 | 8 | import com.mcnz.jee.soap.GetScoreRequest; 9 | import com.mcnz.jee.soap.GetScoreResponse; 10 | import com.mcnz.jee.soap.Score; 11 | 12 | @Endpoint 13 | public class ScoreEndpoint { 14 | 15 | @PayloadRoot(namespace = "http://soap.jee.mcnz.com/", localPart = "getScoreRequest") 16 | @ResponsePayload 17 | public GetScoreResponse getScore(@RequestPayload GetScoreRequest request) { 18 | Score score = new Score(); 19 | if (request.getUser().equalsIgnoreCase("Scrumtuous")) { 20 | score.setWins(100); 21 | } else { 22 | score.setWins(99); 23 | score.setLosses(66); 24 | score.setTies(7); 25 | } 26 | GetScoreResponse response = new GetScoreResponse(); 27 | response.setScore(score); 28 | return response; 29 | } 30 | 31 | } 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /SpringSoapExample/src/main/java/com/mcnz/spring/soap/SpringWithSoapApplication.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.spring.soap; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringWithSoapApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringWithSoapApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /SpringSoapExample/src/main/java/com/mcnz/spring/soap/WebServiceConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.spring.soap; 2 | 3 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.core.io.ClassPathResource; 8 | import org.springframework.ws.config.annotation.EnableWs; 9 | import org.springframework.ws.config.annotation.WsConfigurerAdapter; 10 | import org.springframework.ws.transport.http.MessageDispatcherServlet; 11 | import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; 12 | import org.springframework.xml.xsd.SimpleXsdSchema; 13 | import org.springframework.xml.xsd.XsdSchema; 14 | 15 | @Configuration 16 | @EnableWs 17 | public class WebServiceConfiguration extends WsConfigurerAdapter { 18 | 19 | @Bean 20 | public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) { 21 | MessageDispatcherServlet servlet = new MessageDispatcherServlet(); 22 | servlet.setApplicationContext(applicationContext); 23 | servlet.setTransformWsdlLocations(true); 24 | return new ServletRegistrationBean<>(servlet, "/ws/*"); 25 | } 26 | 27 | @Bean 28 | public XsdSchema scoreSchema() { 29 | return new SimpleXsdSchema(new ClassPathResource("score.xsd")); 30 | } 31 | 32 | @Bean(name = "score") 33 | public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema scoreSchema) { 34 | DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); 35 | wsdl11Definition.setPortTypeName("ScorePort"); 36 | wsdl11Definition.setLocationUri("/ws"); 37 | wsdl11Definition.setTargetNamespace("http://soap.jee.mcnz.com/"); 38 | wsdl11Definition.setSchema(scoreSchema()); 39 | return wsdl11Definition; 40 | } 41 | } 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /SpringSoapExample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=SpringWithSoap 2 | -------------------------------------------------------------------------------- /SpringSoapExample/src/main/resources/score.xsd: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SpringSoapExample/src/test/java/com/mcnz/spring/soap/SpringWithSoapApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.spring.soap; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringWithSoapApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /WA3104-REL_1_1-LabGuide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/WA3104-REL_1_1-LabGuide.pdf -------------------------------------------------------------------------------- /commands.txt: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public interface ScoreRepository extends CrudRepository { 8 | 9 | 10 | } 11 | @Component 12 | public class Score { 13 | 14 | 15 | @Id 16 | Long id; 17 | int wins, losses, ties; 18 | 19 | public Score() { 20 | super(); 21 | } 22 | 23 | 24 | package com.example.demo; 25 | 26 | import java.util.Scanner; 27 | 28 | import org.springframework.beans.factory.annotation.Autowired; 29 | import org.springframework.boot.CommandLineRunner; 30 | import org.springframework.boot.SpringApplication; 31 | import org.springframework.boot.autoconfigure.SpringBootApplication; 32 | 33 | @SpringBootApplication 34 | public class ConsoleAppApplication implements CommandLineRunner { 35 | 36 | //@Autowired 37 | //Score score; 38 | 39 | @Autowired 40 | ScoreRepository scoreRepo; 41 | 42 | public static void main(String[] args) { 43 | SpringApplication.run(ConsoleAppApplication.class, args); 44 | } 45 | 46 | @Override 47 | public void run(String... args) throws Exception { 48 | 49 | Scanner scanner = new Scanner(System.in); 50 | Score score = scoreRepo.findById(Long.valueOf(1)).get(); 51 | String result = ""; 52 | String gesture = ""; 53 | do { 54 | gesture = scanner.next(); 55 | if (gesture.equalsIgnoreCase("rock")) { 56 | score.wins++; 57 | result = "tie"; 58 | } 59 | if (gesture.equalsIgnoreCase("paper")) { 60 | score.ties++; 61 | result = "win"; 62 | } 63 | if (gesture.equalsIgnoreCase("scissors")) { 64 | score.losses++; 65 | result = "loss"; 66 | } 67 | System.out.println("You chose rock. The result is a: " + result); 68 | System.out.println("The score is: " + score); 69 | } while (!gesture.equalsIgnoreCase("q")); 70 | scanner.close(); 71 | 72 | 73 | } 74 | 75 | } 76 | 77 | 78 | 79 | 80 | @Operation(summary = "Non-idempotent update the score by a single unit.") 81 | 82 | @Parameter(description = "New value for the number of wins.") 83 | 84 | @ApiResponse(responseCode = "200", description = "Wins updated, score returned.", 85 | content = { @Content(mediaType = "application/json", 86 | schema = @Schema(implementation = Score.class)) }) 87 | 88 | 89 | @OpenAPIDefinition(info = @Info(title = "Score API - Definition", version = "1.2", description = "Operations to Help Settle Scores")) 90 | 91 | 92 | 93 | @Id 94 | @NotNull(message = "Id cannot be null") 95 | private Integer id; 96 | 97 | @NotBlank 98 | @PositiveOrZero 99 | @Size(min = 0, max = 20) 100 | int wins, losses, ties; 101 | 102 | 103 | @GetMapping("/search") 104 | public Page searchForScores(@ParameterObject Pageable pageable) { 105 | return null; 106 | } 107 | 108 | @RestControllerAdvice 109 | public class GlobalExceptionHandler { 110 | 111 | @ExceptionHandler(HttpMessageNotReadableException.class) 112 | @ResponseStatus(HttpStatus.I_AM_A_TEAPOT) 113 | public ResponseEntity handleTeapotError(RuntimeException exception) { 114 | return new ResponseEntity<>(exception.getMessage(), HttpStatus.I_AM_A_TEAPOT); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /comprehensive-rps/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.example 8 | demo 9 | 0.0.1-SNAPSHOT 10 | jar 11 | 12 | demo 13 | Demo project for Spring Boot 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.0.2.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 27 | 28 | 29 | 30 | 31 | org.apache.tomcat.embed 32 | tomcat-embed-jasper 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-data-jpa 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-web 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-starter-test 48 | test 49 | 50 | 51 | org.apache.derby 52 | derby 53 | 54 | 55 | org.apache.derby 56 | derbyclient 57 | 10.12.1.1 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-configuration-processor 62 | true 63 | 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-starter-thymeleaf 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-devtools 72 | true 73 | 74 | 75 | 76 | org.hibernate 77 | hibernate-entitymanager 78 | 5.2.10.Final 79 | runtime 80 | 81 | 82 | 83 | org.apache.derby 84 | derby 85 | 86 | 87 | org.springframework.boot 88 | spring-boot-configuration-processor 89 | true 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | org.springframework.boot 99 | spring-boot-maven-plugin 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /comprehensive-rps/src/main/java/com/mcnz/rps/spring/GameSummary.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.EnumType; 5 | import javax.persistence.Enumerated; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.persistence.NamedQuery; 10 | import javax.persistence.Table; 11 | 12 | 13 | 14 | @Entity 15 | @Table(name = "GAMESUMMARY") 16 | @NamedQuery(query = "select gs from GameSummary gs", name = "query_find_all_summaries") 17 | public class GameSummary { 18 | 19 | 20 | @Id 21 | @GeneratedValue(strategy=GenerationType.IDENTITY) 22 | private Long id; 23 | @Enumerated(EnumType.STRING) 24 | Gesture clientGesture; 25 | @Enumerated(EnumType.STRING) 26 | Gesture serverGesture; 27 | String result; 28 | java.util.Date date = new java.util.Date(); 29 | 30 | public GameSummary(){} 31 | 32 | public GameSummary(Gesture clientGesture, Gesture serverGesture) { 33 | super(); 34 | this.clientGesture = clientGesture; 35 | this.serverGesture = serverGesture; 36 | } 37 | 38 | public Long getId() { 39 | return id; 40 | } 41 | public void setId(Long id) { 42 | this.id = id; 43 | } 44 | 45 | public Gesture getClientGesture() { 46 | return clientGesture; 47 | } 48 | public void setClientGesture(Gesture clientGesture) { 49 | this.clientGesture = clientGesture; 50 | } 51 | public Gesture getServerGesture() { 52 | return serverGesture; 53 | } 54 | public void setServerGesture(Gesture serverGesture) { 55 | this.serverGesture = serverGesture; 56 | } 57 | public String getResult() { 58 | return result; 59 | } 60 | public void setResult(String result) { 61 | this.result = result; 62 | } 63 | public java.util.Date getDate() { 64 | return date; 65 | } 66 | public void setDate(java.util.Date date) { 67 | this.date = date; 68 | } 69 | 70 | } 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /comprehensive-rps/src/main/java/com/mcnz/rps/spring/GameSummaryRepository.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.PersistenceContext; 7 | import javax.persistence.Query; 8 | import javax.transaction.Transactional; 9 | 10 | import org.springframework.stereotype.Repository; 11 | 12 | @Repository 13 | @Transactional 14 | public class GameSummaryRepository { 15 | 16 | @PersistenceContext 17 | private EntityManager entityManager; 18 | 19 | public GameSummary find(long id) { 20 | return entityManager.find(GameSummary.class, id); 21 | } 22 | 23 | public List findAll() { 24 | Query query = entityManager.createNamedQuery("query_find_all_summaries", GameSummary.class); 25 | return query.getResultList(); 26 | } 27 | 28 | public long insert(GameSummary gs) { 29 | entityManager.persist(gs); 30 | ; 31 | return gs.getId(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /comprehensive-rps/src/main/java/com/mcnz/rps/spring/GameSummaryService.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | public class GameSummaryService { 11 | 12 | @Autowired 13 | private GameSummaryRepository gameSummaryRepository; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /comprehensive-rps/src/main/java/com/mcnz/rps/spring/Gesture.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | public enum Gesture { 4 | 5 | ROCK, PAPER, SCISSORS; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /comprehensive-rps/src/main/java/com/mcnz/rps/spring/RoshamboApplication.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.web.client.RestTemplateBuilder; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.ComponentScan; 9 | import org.springframework.web.client.RestTemplate; 10 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 11 | 12 | @ComponentScan 13 | @EnableWebMvc 14 | @EnableAutoConfiguration 15 | @SpringBootApplication 16 | public class RoshamboApplication { 17 | 18 | 19 | 20 | public static void main(String[] args) { 21 | SpringApplication.run(RoshamboApplication.class, args); 22 | } 23 | 24 | @Bean 25 | public RestTemplate restTemplate(RestTemplateBuilder builder) { 26 | return builder.build(); 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /comprehensive-rps/src/main/java/com/mcnz/rps/spring/Score.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.GeneratedValue; 5 | import javax.persistence.GenerationType; 6 | import javax.persistence.Id; 7 | import javax.persistence.NamedQuery; 8 | import javax.persistence.Table; 9 | 10 | @Entity 11 | @Table(name = "Score") 12 | @NamedQuery(query = "select s from Score s", name = "query_find_all_scores") 13 | public class Score { 14 | 15 | @Id 16 | @GeneratedValue(strategy=GenerationType.IDENTITY) 17 | long id; 18 | 19 | public long getId() { 20 | return id; 21 | } 22 | public void setId(long id) { 23 | this.id = id; 24 | } 25 | private int wins, losses, ties; 26 | 27 | public void increaseWins(){ 28 | System.out.println("Increasing wins in the bean");; 29 | wins++; 30 | } 31 | public void increaseLosses(){ 32 | losses++; 33 | } 34 | public void increaseTies(){ 35 | ties++; 36 | } 37 | 38 | public String toString(){ 39 | String output = "Wins: " + wins + " Ties: " + ties + " Losses: " + losses; 40 | return output; 41 | } 42 | 43 | public int getWins() {return wins;} 44 | public int getLosses() {return losses;} 45 | public int getTies() {return ties;} 46 | 47 | } -------------------------------------------------------------------------------- /comprehensive-rps/src/main/java/com/mcnz/rps/spring/ScoreRepository.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.PersistenceContext; 7 | import javax.persistence.Query; 8 | import javax.transaction.Transactional; 9 | 10 | import org.springframework.stereotype.Repository; 11 | 12 | @Repository 13 | @Transactional 14 | public class ScoreRepository { 15 | 16 | @PersistenceContext 17 | private EntityManager entityManager; 18 | 19 | public Score find(long id) { 20 | return entityManager.find(Score.class, id); 21 | } 22 | 23 | public List findAll() { 24 | Query query = entityManager.createNamedQuery("query_find_all_scores", Score.class); 25 | return query.getResultList(); 26 | } 27 | 28 | public long save(Score score) { 29 | entityManager.persist(score); 30 | System.out.println("Persisted score: " + score.getId() + " wins " + score.getWins() +" ties " + score.getTies()); 31 | return score.getId(); 32 | } 33 | 34 | public Score findScore() { 35 | Score score=null; 36 | Query query = entityManager.createNamedQuery("query_find_all_scores", Score.class); 37 | List scores = query.getResultList(); 38 | System.out.println("Number of scores: " + scores.size()); 39 | if (scores.size()>0) { 40 | //score = (Score)scores.get(0); 41 | score = entityManager.find(Score.class, new Long(1)); 42 | } else { 43 | score = new Score(); 44 | entityManager.persist(score); 45 | System.out.println("New score created with id of: " + score.getId()); 46 | } 47 | 48 | return score; 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /comprehensive-rps/src/main/java/com/mcnz/rps/spring/ScoreService.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | @RestController 11 | public class ScoreService { 12 | 13 | 14 | @Autowired 15 | private ScoreRepository scoreRepository; 16 | 17 | @RequestMapping(value = "/score", method=RequestMethod.GET) 18 | public Score getScore() { 19 | System.out.println("Finding Score"); 20 | return scoreRepository.findScore(); 21 | } 22 | 23 | @RequestMapping(value = "/score/wins", method=RequestMethod.GET) 24 | public int getWins() { 25 | Score score = scoreRepository.findScore(); 26 | return score.getWins(); 27 | } 28 | 29 | @RequestMapping(value = "/score/losses", method=RequestMethod.GET) 30 | public int getLosses() { 31 | Score score = scoreRepository.findScore(); 32 | return score.getLosses(); 33 | } 34 | 35 | @RequestMapping(value = "/score/ties", method=RequestMethod.GET) 36 | public int getTies() { 37 | Score score = scoreRepository.findScore(); 38 | return score.getTies(); 39 | } 40 | 41 | @RequestMapping(value = "/score/wins", method=RequestMethod.POST) 42 | public boolean increaseWins() { 43 | System.out.println("POST wins"); 44 | Score score = scoreRepository.findScore(); 45 | score.increaseWins(); 46 | System.out.println(score.getId());; 47 | scoreRepository.save(score); 48 | return true; 49 | } 50 | 51 | @RequestMapping(value = "/score/losses", method=RequestMethod.POST) 52 | public boolean increaseLosses() { 53 | System.out.println("POST losses"); 54 | Score score = scoreRepository.findScore(); 55 | score.increaseLosses(); 56 | System.out.println(score.getId());; 57 | scoreRepository.save(score); 58 | return true; 59 | } 60 | 61 | @RequestMapping(value = "/score/ties", method=RequestMethod.POST) 62 | public boolean increaseTies() { 63 | System.out.println("POST ties"); 64 | Score score = scoreRepository.findScore(); 65 | score.increaseTies(); 66 | System.out.println(score.getId());; 67 | scoreRepository.save(score); 68 | return true; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /comprehensive-rps/src/main/java/com/mcnz/rps/spring/WebController.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.client.RestTemplate; 8 | 9 | @Controller 10 | public class WebController { 11 | 12 | @GetMapping("/playagame") 13 | public String playRoshambo(@RequestParam(name = "choice", required=false) String choice, Model model) { 14 | System.out.println("In play"); 15 | if (choice == null) { 16 | return "index"; 17 | } 18 | System.out.println("Choice: " + choice); 19 | 20 | GameSummary gameSummary = new GameSummary(); 21 | gameSummary.clientGesture = Gesture.valueOf(choice.toUpperCase()); 22 | gameSummary.serverGesture = Gesture.ROCK; 23 | 24 | String result = "tie"; 25 | if (gameSummary.clientGesture.equals(Gesture.PAPER)) { 26 | result = "win"; 27 | RestTemplate restTemplate = new RestTemplate(); 28 | restTemplate.postForObject("http://localhost:8080/score/wins", "", Object.class); 29 | } 30 | if (gameSummary.clientGesture.equals(Gesture.SCISSORS)) { 31 | result = "lose"; 32 | RestTemplate restTemplate = new RestTemplate(); 33 | restTemplate.postForObject("http://localhost:8080/score/losses", "", Object.class); 34 | } 35 | if (result == "tie") { 36 | RestTemplate restTemplate = new RestTemplate(); 37 | restTemplate.postForObject("http://localhost:8080/score/ties", "", Object.class); 38 | } 39 | gameSummary.setResult(result); 40 | 41 | RestTemplate restTemplate = new RestTemplate(); 42 | Score score = restTemplate.getForObject("http://localhost:8080/score", Score.class); 43 | 44 | model.addAttribute("gameSummary", gameSummary); 45 | model.addAttribute("score", score); 46 | // request.getRequestDispatcher("index.jsp").forward(request, response); 47 | 48 | return "results"; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /comprehensive-rps/src/main/resources/META-INF/xxxpersistence.xmlxxx: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | org.hibernate.ejb.HibernatePersistence 9 | 10 | com.mcnz.rps.GameSummary 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /comprehensive-rps/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:derby://localhost:1527/OEDB 2 | spring.datasource.driver-class-name=org.apache.derby.jdbc.ClientDriver 3 | spring.datasource.username=rps 4 | spring.datasource.jdbc-url=jdbc:derby://localhost:1527/OEDB 5 | app.datasource.jdbc-url=jdbc:derby://localhost:1527/OEDB 6 | spring.thymeleaf.enabled=true 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /comprehensive-rps/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Roshambo! 4 | 5 | 6 | 7 |

Which one will it be?

8 | 9 | rock 10 | paper 11 | scissors 12 | 13 | 14 | -------------------------------------------------------------------------------- /comprehensive-rps/src/main/resources/templates/results.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Getting Started: Serving Web Content 5 | 6 | 7 | 8 | 9 | rock 10 | paper 11 | scissors 12 | 13 | 14 | 15 |

16 |

17 |

18 | 19 | 20 | -------------------------------------------------------------------------------- /labs/Lab 06 - Utilizing Runners, Arguments, and Environment.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/Lab 06 - Utilizing Runners, Arguments, and Environment.zip -------------------------------------------------------------------------------- /labs/Lab 07 - Using Multiple ViewResolver.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/Lab 07 - Using Multiple ViewResolver.zip -------------------------------------------------------------------------------- /labs/Lab 08 - Implementing Spring Data REST.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/Lab 08 - Implementing Spring Data REST.zip -------------------------------------------------------------------------------- /labs/Lab 09 - Implementing OAuth2 using Spring Boot.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/Lab 09 - Implementing OAuth2 using Spring Boot.zip -------------------------------------------------------------------------------- /labs/Lab 11 - Authentication with JWT.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/Lab 11 - Authentication with JWT.zip -------------------------------------------------------------------------------- /labs/Lab 12 - Spring Boot Actuator.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/Lab 12 - Spring Boot Actuator.zip -------------------------------------------------------------------------------- /labs/LabGuide-Protected.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/LabGuide-Protected.pdf -------------------------------------------------------------------------------- /labs/Restaurant-Microservice.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/Restaurant-Microservice.zip -------------------------------------------------------------------------------- /labs/Spring-Boot-AMQP-Starter.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/Spring-Boot-AMQP-Starter.zip -------------------------------------------------------------------------------- /labs/Spring-Boot-Basic-Security-Starter.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/Spring-Boot-Basic-Security-Starter.zip -------------------------------------------------------------------------------- /labs/Spring-Boot-JDBC-Starter.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/Spring-Boot-JDBC-Starter.zip -------------------------------------------------------------------------------- /labs/Spring-Boot-MVC-Starter.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/Spring-Boot-MVC-Starter.zip -------------------------------------------------------------------------------- /labs/Spring-Boot-REST-Client-Starter.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/Spring-Boot-REST-Client-Starter.zip -------------------------------------------------------------------------------- /labs/Spring-Boot-REST-Starter.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/Spring-Boot-REST-Starter.zip -------------------------------------------------------------------------------- /labs/WA3104-REL_1_1-LabGuide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/WA3104-REL_1_1-LabGuide.pdf -------------------------------------------------------------------------------- /labs/files.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /labs/labs 1-5.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/labs 1-5.zip -------------------------------------------------------------------------------- /labs/spring-controllers-starter.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/spring-controllers-starter.zip -------------------------------------------------------------------------------- /labs/spring-data-rest-starter.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/labs/spring-data-rest-starter.zip -------------------------------------------------------------------------------- /settling-scores/.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 | -------------------------------------------------------------------------------- /settling-scores/.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 | -------------------------------------------------------------------------------- /settling-scores/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 https://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 | -------------------------------------------------------------------------------- /settling-scores/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.1 9 | 10 | 11 | com.mcnz.rps 12 | settling-scores 13 | 0.0.1-SNAPSHOT 14 | settling-scores 15 | Demo project for Spring Boot and RESTful APIs 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 17 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-devtools 41 | runtime 42 | true 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter-test 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-maven-plugin 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /settling-scores/src/main/java/com/mcnz/rps/Score.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | public class Score { 4 | 5 | int wins; 6 | int losses; 7 | int ties; 8 | 9 | 10 | public Score() {} 11 | 12 | public Score(int wins, int losses, int ties) { 13 | super(); 14 | this.wins = wins; 15 | this.losses = losses; 16 | this.ties = ties; 17 | } 18 | 19 | public int getWins() { 20 | return wins; 21 | } 22 | public void setWins(int wins) { 23 | this.wins = wins; 24 | } 25 | public int getLosses() { 26 | return losses; 27 | } 28 | public void setLosses(int losses) { 29 | this.losses = losses; 30 | } 31 | public int getTies() { 32 | return ties; 33 | } 34 | public void setTies(int ties) { 35 | this.ties = ties; 36 | } 37 | 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /settling-scores/src/main/java/com/mcnz/rps/ScoreController.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | import org.springframework.web.bind.annotation.CrossOrigin; 4 | import org.springframework.web.bind.annotation.DeleteMapping; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PatchMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.PutMapping; 10 | import org.springframework.web.bind.annotation.RequestBody; 11 | import org.springframework.web.bind.annotation.RequestParam; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | @CrossOrigin 15 | @RestController 16 | public class ScoreController { 17 | 18 | static Score score = new Score(30, 20, 10); 19 | 20 | @PatchMapping("/score/wins") 21 | public Score setWins(@RequestParam(name="new-value") int newValue) { 22 | score.wins = newValue; 23 | return score; 24 | } 25 | 26 | @GetMapping("/score/health-check") 27 | public String healthCheck() { 28 | return "Situation normal everything fine"; 29 | } 30 | 31 | @GetMapping("/score") 32 | public Score getScore() { 33 | if (score == null) { 34 | score = new Score(); 35 | } 36 | return score; 37 | } 38 | 39 | @PostMapping("/score/wins") 40 | public Score increaseWins() { 41 | score.wins++; 42 | return score; 43 | } 44 | 45 | @PostMapping("/score/losses") 46 | public Score increaseLosses() { 47 | score.losses++; 48 | return score; 49 | } 50 | 51 | @PostMapping("/score/ties") 52 | public Score increaseTies() { 53 | score.ties++; 54 | return score; 55 | } 56 | 57 | @PutMapping("/score") 58 | public Score setScore(@RequestBody Score newScore) { 59 | score = newScore; 60 | return score; 61 | } 62 | 63 | 64 | @DeleteMapping("/score") 65 | public void deleteScore() { 66 | score = null; 67 | } 68 | 69 | @GetMapping("/score/{winsLossesOrTies}") 70 | public int getWinsLossesOrTies(@PathVariable String winsLossesOrTies) { 71 | int valueToReturn; 72 | if (winsLossesOrTies.equalsIgnoreCase("wins")) { 73 | valueToReturn = score.wins; 74 | } else if (winsLossesOrTies.equalsIgnoreCase("losses")){ 75 | valueToReturn = score.losses; 76 | } else { 77 | valueToReturn = score.ties; 78 | } 79 | return valueToReturn; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /settling-scores/src/main/java/com/mcnz/rps/SettlingScoresApplication.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SettlingScoresApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SettlingScoresApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /settling-scores/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=settling-scores 2 | -------------------------------------------------------------------------------- /settling-scores/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Rock Paper Scissor App 4 | 5 | 6 | 7 | Which one will it be?

8 | rock    9 | paper    10 | scissors 11 | 12 |



13 | 14 |
15 |
16 | 17 | 18 | 19 | 20 | 21 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /settling-scores/src/test/java/com/mcnz/rps/SettlingScoresApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SettlingScoresApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /simple-spring-mvc-rps/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /simple-spring-mvc-rps/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | spring-mvc-rps 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.common.project.facet.core.builder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.springframework.ide.eclipse.core.springbuilder 20 | 21 | 22 | 23 | 24 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 25 | 26 | 27 | 28 | 29 | org.eclipse.m2e.core.maven2Builder 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.ide.eclipse.core.springnature 36 | org.eclipse.jdt.core.javanature 37 | org.eclipse.m2e.core.maven2Nature 38 | org.eclipse.wst.common.project.facet.core.nature 39 | 40 | 41 | -------------------------------------------------------------------------------- /simple-spring-mvc-rps/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /simple-spring-mvc-rps/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.mcnz.rps.spring 7 | roshambo 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | spring-mvc-rps 12 | rps 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.3.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-thymeleaf 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-devtools 40 | runtime 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-maven-plugin 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /simple-spring-mvc-rps/src/main/java/com/mcnz/rps/smvc/SpringMvcRpsApplication.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.smvc; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringMvcRpsApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringMvcRpsApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /simple-spring-mvc-rps/src/main/java/com/mcnz/rps/smvc/WebController.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import org.springframework.stereotype.*; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.*; 6 | 7 | 8 | @Controller 9 | public class WebController { 10 | 11 | @GetMapping ("/playagame") 12 | public String playGame( 13 | @RequestParam(name="choice", required=false) 14 | String theChoice, 15 | Model model) { 16 | 17 | if (theChoice == null) { 18 | return "index"; 19 | } 20 | 21 | String theOutcome = "error"; 22 | if (theChoice.equals("rock")) { 23 | theOutcome = "tie"; 24 | } 25 | if (theChoice.equals("paper")) { 26 | theOutcome = "win"; 27 | } 28 | if (theChoice.equals("scissors")) { 29 | theOutcome = "loss"; 30 | } 31 | 32 | model.addAttribute("outcome", theOutcome); 33 | return "results"; 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /simple-spring-mvc-rps/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/simple-spring-mvc-rps/src/main/resources/application.properties -------------------------------------------------------------------------------- /simple-spring-mvc-rps/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Hello World

7 | 8 |

Which one will it be?

9 | 10 | rock 11 | paper 12 | scissors 13 | 14 | 15 | -------------------------------------------------------------------------------- /simple-spring-mvc-rps/src/main/resources/templates/results.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

9 | 10 | This is the results.html page! 11 | 12 | 13 | -------------------------------------------------------------------------------- /simple-spring-mvc-rps/src/test/java/com/mcnz/rps/smvc/SpringMvcRpsApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.smvc; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringMvcRpsApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /simple-spring-rest-keeping-score/.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 | -------------------------------------------------------------------------------- /simple-spring-rest-keeping-score/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /simple-spring-rest-keeping-score/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.4.5 9 | 10 | 11 | com.mcnz.rps.rest 12 | KeepingScore 13 | 0.0.1-SNAPSHOT 14 | war 15 | KeepingScore 16 | Demo project for Spring Boot 17 | 18 | 11 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-web 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-devtools 29 | runtime 30 | true 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-tomcat 35 | provided 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-test 40 | test 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /simple-spring-rest-keeping-score/src/main/java/com/mcnz/rps/rest/KeepingScoreApplication.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.rest; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class KeepingScoreApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(KeepingScoreApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /simple-spring-rest-keeping-score/src/main/java/com/mcnz/rps/rest/Score.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.rest; 2 | 3 | public class Score { 4 | 5 | public int wins; 6 | public int losses; 7 | public int ties; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /simple-spring-rest-keeping-score/src/main/java/com/mcnz/rps/rest/ScoreService.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.rest; 2 | 3 | import org.springframework.web.bind.annotation.CrossOrigin; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @CrossOrigin 8 | @RestController 9 | public class ScoreService { 10 | 11 | static Score score = new Score(); 12 | 13 | @GetMapping("/score/increasewins") 14 | public Score increaseWins() { 15 | score.wins = score.wins + 1; 16 | return score; 17 | 18 | } 19 | 20 | @GetMapping("/score/increaselosses") 21 | public Score increaseLosses() { 22 | score.losses = score.losses + 1; 23 | return score; 24 | 25 | } 26 | 27 | @GetMapping("/score/increaseties") 28 | public Score increaseTies() { 29 | score.wins = score.ties + 1; 30 | return score; 31 | } 32 | 33 | @GetMapping("/score") 34 | public Score getScore() { 35 | return score; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /simple-spring-rest-keeping-score/src/main/java/com/mcnz/rps/rest/ServletInitializer.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.rest; 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder; 4 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 5 | 6 | public class ServletInitializer extends SpringBootServletInitializer { 7 | 8 | @Override 9 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 10 | return application.sources(KeepingScoreApplication.class); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /simple-spring-rest-keeping-score/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /simple-spring-rest-keeping-score/src/test/java/com/mcnz/rps/rest/KeepingScoreApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.rest; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class KeepingScoreApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-file-upload/.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 | -------------------------------------------------------------------------------- /spring-boot-file-upload/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /spring-boot-file-upload/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cameronmcnz/spring-boot-examples/5d48cc368965539c57acc89e967e4ae413e2895c/spring-boot-file-upload/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-boot-file-upload/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-boot-file-upload/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /spring-boot-file-upload/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.4.RELEASE 9 | 10 | 11 | com.mcnz.spring 12 | spring-boot-uploader 13 | 0.0.1-SNAPSHOT 14 | spring-boot-uploader 15 | Spring uploader 16 | 17 | 18 | 11 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-thymeleaf 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-devtools 34 | runtime 35 | true 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-test 40 | test 41 | 42 | 43 | org.junit.vintage 44 | junit-vintage-engine 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-maven-plugin 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /spring-boot-file-upload/src/main/java/com/mcnz/spring/SpringBootUploaderApplication.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.spring; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootUploaderApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootUploaderApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-file-upload/src/main/java/com/mcnz/spring/SpringFileUploadController.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.spring; 2 | 3 | import java.io.File; 4 | 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.multipart.MultipartFile; 12 | 13 | @Controller 14 | public class SpringFileUploadController { 15 | 16 | @GetMapping("/index") 17 | public String hello() { 18 | return "uploader"; 19 | } 20 | 21 | @PostMapping("/upload") 22 | public ResponseEntity handleFileUpload( @RequestParam("file") MultipartFile file ) { 23 | String fileName = file.getOriginalFilename(); 24 | 25 | try { 26 | file.transferTo( new File("C:\\upload\\" + fileName)); 27 | } catch (Exception e) { 28 | return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); 29 | } 30 | return ResponseEntity.ok("File uploaded successfully."); 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-file-upload/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-file-upload/src/main/resources/templates/uploader.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Ajax Spring File Upload Example 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /spring-boot-file-upload/src/test/java/com/mcnz/spring/SpringBootUploaderApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.spring; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringBootUploaderApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-configuration-example/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.6.RELEASE 9 | 10 | 11 | com.mcnz.spring.config.example 12 | spring-configuration-example 13 | 1.0-SNAPSHOT 14 | spring-configuration-example 15 | spring configuration tutorial 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-configuration-processor 35 | true 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-maven-plugin 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /spring-configuration-example/src/main/java/com/mcnz/spring/configuration/SpringBootConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.spring.configuration; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import org.springframework.boot.context.properties.ConfigurationProperties; 7 | import org.springframework.stereotype.Component; 8 | 9 | @ConfigurationProperties(prefix="spring.boot.config.example") 10 | @Component 11 | public class SpringBootConfiguration { 12 | 13 | private final InnerClass innerClass = new InnerClass(); 14 | 15 | public InnerClass getInnerClass() { 16 | return innerClass; 17 | } 18 | 19 | @ConfigurationProperties(prefix="innerClass") 20 | public class InnerClass { 21 | private String property1; 22 | private String property2; 23 | private String property3; 24 | public String getProperty1() {return property1;} 25 | public void setProperty1(String p) { property1 = p; } 26 | public String getProperty2() {return property2;} 27 | public void setProperty2(String p) { property2 = p; } 28 | public String getProperty3() {return property3;} 29 | public void setProperty3(String p) { property3 = p; } 30 | } 31 | 32 | 33 | 34 | 35 | private String company; private int suite; private boolean active; private 36 | Map map; private List list; 37 | 38 | public Map getMap() {return map;} public void 39 | setMap(Map m) {map = m;} public List getList() 40 | {return list;} public void setList(List l) {list = l;} 41 | 42 | public String getCompany() { return company; } public void setCompany(String 43 | c) { company = c; } public int getSuite() { return suite; } public void 44 | setSuite(int s) { suite = s; } public boolean isActive() { return active; } 45 | public void setActive(boolean a) { active = a; } 46 | 47 | 48 | 49 | } 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /spring-configuration-example/src/main/java/com/mcnz/spring/configuration/SpringConfigurationExampleApplication.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.spring.configuration; 2 | 3 | import org.springframework.beans.factory.annotation.*; 4 | import org.springframework.boot.*; 5 | import org.springframework.boot.autoconfigure.*; 6 | 7 | @SpringBootApplication 8 | public class SpringConfigurationExampleApplication 9 | implements CommandLineRunner { 10 | 11 | @Autowired 12 | SpringBootConfiguration config; 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SpringConfigurationExampleApplication.class, args); 16 | } 17 | 18 | @Override 19 | public void run(String... args) throws Exception { 20 | System.out.println(config.getCompany()); 21 | System.out.println(config.getSuite()); 22 | System.out.println(config.isActive()); 23 | 24 | System.out.println(config.getList().get(0)); 25 | System.out.println(config.getMap()); 26 | System.out.println(config.getInnerClass().getProperty1()); 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spring-configuration-example/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | #Spring Boot configuration file exmaple 3 | # simple spring configurationd data 4 | spring.boot.config.example.company = "Dreamix" 5 | spring.boot.config.example.suite = 1113 6 | spring.boot.config.example.active = true 7 | 8 | # list data in spring configuration file 9 | spring.boot.config.example.list[0] = "list-data-0" 10 | spring.boot.config.example.list[1] = "list-data-1" 11 | 12 | 13 | # simple map in a spring configuration file 14 | spring.boot.config.example.map.key1="value1" 15 | spring.boot.config.example.map.key2="value2" 16 | 17 | # inner class in Spring config file 18 | spring.boot.config.example.innerClass.property1 = "annotations" 19 | spring.boot.config.example.innerClass.property2 = "xml" 20 | spring.boot.config.example.innerClass.property3 = "YAML" -------------------------------------------------------------------------------- /spring-console-app/.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 | -------------------------------------------------------------------------------- /spring-console-app/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.2 9 | 10 | 11 | com.example 12 | my-console-app 13 | 0.0.1-SNAPSHOT 14 | my-console-app 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 17 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-data-jdbc 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-devtools 41 | runtime 42 | true 43 | 44 | 45 | com.h2database 46 | h2 47 | runtime 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-starter-test 52 | test 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-starter-web 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /spring-console-app/src/main/java/com/example/demo/ConsoleAppApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import java.util.Scanner; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | 10 | @SpringBootApplication 11 | public class ConsoleAppApplication implements CommandLineRunner { 12 | 13 | //@Autowired 14 | //Score score; 15 | 16 | @Autowired 17 | ScoreRepository scoreRepo; 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(ConsoleAppApplication.class, args); 21 | } 22 | 23 | @Override 24 | public void run(String... args) throws Exception { 25 | 26 | Scanner scanner = new Scanner(System.in); 27 | Score score = scoreRepo.findById(Long.valueOf(1)).get(); 28 | String result = ""; 29 | String gesture = ""; 30 | do { 31 | gesture = scanner.next(); 32 | if (gesture.equalsIgnoreCase("rock")) { 33 | score.wins++; 34 | result = "tie"; 35 | } 36 | if (gesture.equalsIgnoreCase("paper")) { 37 | score.ties++; 38 | result = "win"; 39 | } 40 | if (gesture.equalsIgnoreCase("scissors")) { 41 | score.losses++; 42 | result = "loss"; 43 | } 44 | System.out.println("You chose rock. The result is a: " + result); 45 | System.out.println("The score is: " + score); 46 | } while (!gesture.equalsIgnoreCase("q")); 47 | scanner.close(); 48 | 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-console-app/src/main/java/com/example/demo/MyConsoleAppApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class MyConsoleAppApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MyConsoleAppApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-console-app/src/main/java/com/example/demo/Score.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class Score { 8 | 9 | 10 | @Id 11 | Long id; 12 | int wins, losses, ties; 13 | 14 | public Score() { 15 | super(); 16 | } 17 | 18 | public Score(int wins, int losses, int ties) { 19 | super(); 20 | this.wins = wins; 21 | this.losses = losses; 22 | this.ties = ties; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "Score [id=" + id + ", wins=" + wins + ", losses=" + losses + ", ties=" + ties + "]"; 28 | } 29 | 30 | public Long getId() { 31 | return id; 32 | } 33 | 34 | public void setId(Long id) { 35 | this.id = id; 36 | } 37 | 38 | 39 | 40 | public int getWins() { 41 | return wins; 42 | } 43 | 44 | public void setWins(int wins) { 45 | this.wins = wins; 46 | } 47 | 48 | public int getLosses() { 49 | return losses; 50 | } 51 | 52 | public void setLosses(int losses) { 53 | this.losses = losses; 54 | } 55 | 56 | public int getTies() { 57 | return ties; 58 | } 59 | 60 | public void setTies(int ties) { 61 | this.ties = ties; 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /spring-console-app/src/main/java/com/example/demo/ScoreRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public interface ScoreRepository extends CrudRepository { 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /spring-console-app/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=my-console-app 2 | -------------------------------------------------------------------------------- /spring-console-app/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | insert into SCORE (ID, WINS, LOSSES, TIES) values(1, 30, 20, 10); 2 | 3 | 4 | -------------------------------------------------------------------------------- /spring-console-app/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE SCORE ( id INTEGER auto_increment NOT NULL, WINS INTEGER NOT NULL, LOSSES INTEGER NOT NULL, TIES INTEGER NOT NULL,PRIMARY KEY (id)) -------------------------------------------------------------------------------- /spring-console-app/src/test/java/com/example/demo/MyConsoleAppApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class MyConsoleAppApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-ioc-example/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /spring-ioc-example/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | rps-ioc-app 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /spring-ioc-example/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | com.mcnz.ioc 4 | rps-ioc-app 5 | 0.0.1-SNAPSHOT 6 | 7 | 8 | 9 | 10 | org.springframework 11 | spring-context 12 | 3.2.3.RELEASE 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /spring-ioc-example/src/main/java/com/mcnz/ioc/example/GameService.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.ioc.example; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | public class GameService { 7 | 8 | //Score score = new Score(); 9 | ApplicationContext context = 10 | new ClassPathXmlApplicationContext("spring-context.xml"); 11 | Score score = context.getBean("thescore", Score.class); 12 | 13 | 14 | public void playTheGame(String clientGesture) { 15 | if (clientGesture.equalsIgnoreCase("scissors")) { score.losses++;} 16 | if (clientGesture.equalsIgnoreCase("paper")) { score.wins++;} 17 | if (clientGesture.equalsIgnoreCase("rock")) { score.ties++;} 18 | } 19 | 20 | 21 | public static void main (String args[]) { 22 | GameService gs = new GameService(); 23 | gs.playTheGame("scissors"); 24 | gs.playTheGame("paper"); 25 | gs.playTheGame("scissors"); 26 | gs.playTheGame("paper"); 27 | 28 | System.out.print("Wins: " + gs.score.wins); 29 | System.out.print("..Losses: " + gs.score.losses); 30 | System.out.print("..Ties: " + gs.score.ties); 31 | 32 | 33 | 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-ioc-example/src/main/java/com/mcnz/ioc/example/Score.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.ioc.example; 2 | 3 | public class Score { 4 | 5 | int wins, losses, ties; 6 | 7 | @Override 8 | public String toString() { 9 | return "Score [wins=" + wins + ", losses=" + losses + ", ties=" + ties + "]"; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-ioc-example/src/main/resources/spring-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/game.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Rock Paper Scissors!!! 4 | 5 | 6 | 7 | 8 | Which one will it be?
9 | rock 10 | paper 11 | scissors 12 | 13 |
14 |

15 |
16 |
17 |
18 |
19 | 20 | 21 | 22 | 23 | 64 | 65 | 66 | 88 | 89 | 123 | 124 | 190 | 191 | 224 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.mcnz.rps.spring 7 | roshambo 8 | 1.0 9 | jar 10 | 11 | roshambo 12 | rock-paper-scissors spring boot app 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.4.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | rps 26 | 27 | 28 | 29 | 30 | 31 | org.apache.tomcat.embed 32 | tomcat-embed-jasper 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-data-jpa 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-thymeleaf 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-web 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-devtools 50 | runtime 51 | 52 | 53 | mysql 54 | mysql-connector-java 55 | runtime 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-starter-test 60 | test 61 | 62 | 63 | org.hibernate 64 | hibernate-entitymanager 65 | 5.2.10.Final 66 | runtime 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | org.springframework.boot 77 | spring-boot-maven-plugin 78 | 79 | 80 | 81 | com.spotify 82 | dockerfile-maven-plugin 83 | 1.3.6 84 | 85 | rps/roshambo 86 | 87 | target/roshambo-1.0.jar 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/src/main/java/com/mcnz/rps/spring/GameSummary.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.EnumType; 5 | import javax.persistence.Enumerated; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.persistence.NamedQuery; 10 | import javax.persistence.Table; 11 | 12 | 13 | 14 | @Entity 15 | @Table(name = "GAMESUMMARY") 16 | @NamedQuery(query = "select gs from GameSummary gs", name = "query_find_all_summaries") 17 | public class GameSummary { 18 | 19 | 20 | @Id 21 | @GeneratedValue(strategy=GenerationType.IDENTITY) 22 | private Long id; 23 | @Enumerated(EnumType.STRING) 24 | Gesture clientGesture; 25 | @Enumerated(EnumType.STRING) 26 | Gesture serverGesture; 27 | String result; 28 | java.util.Date date = new java.util.Date(); 29 | 30 | public GameSummary(){} 31 | 32 | public GameSummary(Gesture clientGesture, Gesture serverGesture) { 33 | super(); 34 | this.clientGesture = clientGesture; 35 | this.serverGesture = serverGesture; 36 | } 37 | 38 | public Long getId() { 39 | return id; 40 | } 41 | public void setId(Long id) { 42 | this.id = id; 43 | } 44 | 45 | public Gesture getClientGesture() { 46 | return clientGesture; 47 | } 48 | public void setClientGesture(Gesture clientGesture) { 49 | this.clientGesture = clientGesture; 50 | } 51 | public Gesture getServerGesture() { 52 | return serverGesture; 53 | } 54 | public void setServerGesture(Gesture serverGesture) { 55 | this.serverGesture = serverGesture; 56 | } 57 | public String getResult() { 58 | return result; 59 | } 60 | public void setResult(String result) { 61 | this.result = result; 62 | } 63 | public java.util.Date getDate() { 64 | return date; 65 | } 66 | public void setDate(java.util.Date date) { 67 | this.date = date; 68 | } 69 | 70 | } 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/src/main/java/com/mcnz/rps/spring/GameSummaryRepository.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.PersistenceContext; 7 | import javax.persistence.Query; 8 | import javax.transaction.Transactional; 9 | 10 | import org.springframework.stereotype.Repository; 11 | 12 | @Repository 13 | @Transactional 14 | public class GameSummaryRepository { 15 | 16 | @PersistenceContext 17 | private EntityManager entityManager; 18 | 19 | public GameSummary find(long id) { 20 | return entityManager.find(GameSummary.class, id); 21 | } 22 | 23 | public List findAll() { 24 | Query query = entityManager.createNamedQuery("query_find_all_summaries", GameSummary.class); 25 | return query.getResultList(); 26 | } 27 | 28 | public long insert(GameSummary gs) { 29 | entityManager.persist(gs); 30 | ; 31 | return gs.getId(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/src/main/java/com/mcnz/rps/spring/GameSummaryService.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | public class GameSummaryService { 11 | 12 | @Autowired 13 | private GameSummaryRepository gameSummaryRepository; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/src/main/java/com/mcnz/rps/spring/Gesture.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | public enum Gesture { 4 | 5 | ROCK, PAPER, SCISSORS; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/src/main/java/com/mcnz/rps/spring/RoshamboApplication.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.web.client.RestTemplateBuilder; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.ComponentScan; 9 | import org.springframework.web.client.RestTemplate; 10 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 11 | 12 | @ComponentScan 13 | @EnableWebMvc 14 | @EnableAutoConfiguration 15 | @SpringBootApplication 16 | public class RoshamboApplication { 17 | 18 | 19 | 20 | public static void main(String[] args) { 21 | SpringApplication.run(RoshamboApplication.class, args); 22 | } 23 | 24 | @Bean 25 | public RestTemplate restTemplate(RestTemplateBuilder builder) { 26 | return builder.build(); 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/src/main/java/com/mcnz/rps/spring/Score.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.GeneratedValue; 5 | import javax.persistence.GenerationType; 6 | import javax.persistence.Id; 7 | import javax.persistence.NamedQuery; 8 | import javax.persistence.Table; 9 | 10 | @Entity 11 | @Table(name = "score", schema="wasadmin") 12 | @NamedQuery(query = "select s from Score s", name = "query_find_all_scores") 13 | public class Score { 14 | 15 | @Id 16 | @GeneratedValue(strategy=GenerationType.IDENTITY) 17 | long id; 18 | 19 | public long getId() { 20 | return id; 21 | } 22 | public void setId(long id) { 23 | this.id = id; 24 | } 25 | private int wins, losses, ties; 26 | 27 | public void increaseWins(){ 28 | System.out.println("Increasing wins in the bean");; 29 | wins++; 30 | } 31 | public void increaseLosses(){ 32 | losses++; 33 | } 34 | public void increaseTies(){ 35 | ties++; 36 | } 37 | 38 | public String toString(){ 39 | String output = "Wins: " + wins + " Ties: " + ties + " Losses: " + losses; 40 | return output; 41 | } 42 | 43 | public int getWins() {return wins;} 44 | public int getLosses() {return losses;} 45 | public int getTies() {return ties;} 46 | 47 | } -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/src/main/java/com/mcnz/rps/spring/ScoreRepository.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.PersistenceContext; 7 | import javax.persistence.Query; 8 | import javax.transaction.Transactional; 9 | 10 | import org.springframework.stereotype.Repository; 11 | 12 | @Repository 13 | @Transactional 14 | public class ScoreRepository { 15 | 16 | @PersistenceContext 17 | private EntityManager entityManager; 18 | 19 | public Score find(long id) { 20 | return entityManager.find(Score.class, id); 21 | } 22 | 23 | public List findAll() { 24 | Query query = entityManager.createNamedQuery("query_find_all_scores", Score.class); 25 | return query.getResultList(); 26 | } 27 | 28 | public long save(Score score) { 29 | entityManager.persist(score); 30 | System.out.println("Persisted score: " + score.getId() + " wins " + score.getWins() +" ties " + score.getTies()); 31 | return score.getId(); 32 | } 33 | 34 | public Score findScore() { 35 | System.out.println("Finding the score"); 36 | Score score=null; 37 | Query query = entityManager.createNamedQuery("query_find_all_scores", Score.class); 38 | List scores = query.getResultList(); 39 | System.out.println("Number of scores: " + scores.size()); 40 | if (scores.size()>0) { 41 | //score = (Score)scores.get(0); 42 | score = entityManager.find(Score.class, new Long(1)); 43 | } else { 44 | score = new Score(); 45 | score.setId(System.currentTimeMillis()); 46 | entityManager.persist(score); 47 | System.out.println("New score created with id of: " + score.getId()); 48 | } 49 | 50 | return score; 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/src/main/java/com/mcnz/rps/spring/ScoreService.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | @RestController 11 | public class ScoreService { 12 | 13 | 14 | @Autowired 15 | private ScoreRepository scoreRepository; 16 | 17 | @RequestMapping(value = "/score", method=RequestMethod.GET) 18 | public Score getScore() { 19 | System.out.println("Finding Score"); 20 | return scoreRepository.findScore(); 21 | } 22 | 23 | @RequestMapping(value = "/score/wins", method=RequestMethod.GET) 24 | public int getWins() { 25 | Score score = scoreRepository.findScore(); 26 | return score.getWins(); 27 | } 28 | 29 | @RequestMapping(value = "/score/losses", method=RequestMethod.GET) 30 | public int getLosses() { 31 | Score score = scoreRepository.findScore(); 32 | return score.getLosses(); 33 | } 34 | 35 | @RequestMapping(value = "/score/ties", method=RequestMethod.GET) 36 | public int getTies() { 37 | Score score = scoreRepository.findScore(); 38 | return score.getTies(); 39 | } 40 | 41 | @RequestMapping(value = "/score/wins", method=RequestMethod.POST) 42 | public boolean increaseWins() { 43 | System.out.println("POST wins"); 44 | Score score = scoreRepository.findScore(); 45 | score.increaseWins(); 46 | System.out.println(score.getId());; 47 | scoreRepository.save(score); 48 | return true; 49 | } 50 | 51 | @RequestMapping(value = "/score/losses", method=RequestMethod.POST) 52 | public boolean increaseLosses() { 53 | System.out.println("POST losses"); 54 | Score score = scoreRepository.findScore(); 55 | score.increaseLosses(); 56 | System.out.println(score.getId());; 57 | scoreRepository.save(score); 58 | return true; 59 | } 60 | 61 | @RequestMapping(value = "/score/ties", method=RequestMethod.POST) 62 | public boolean increaseTies() { 63 | System.out.println("POST ties"); 64 | Score score = scoreRepository.findScore(); 65 | score.increaseTies(); 66 | System.out.println(score.getId());; 67 | scoreRepository.save(score); 68 | return true; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/src/main/java/com/mcnz/rps/spring/WebController.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps.spring; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.client.RestTemplate; 8 | 9 | @Controller 10 | public class WebController { 11 | 12 | @GetMapping("/playagame") 13 | public String playRoshambo(@RequestParam(name = "choice", required=false) String choice, Model model) { 14 | System.out.println("In play"); 15 | if (choice == null) { 16 | return "index"; 17 | } 18 | System.out.println("Choice: " + choice); 19 | 20 | GameSummary gameSummary = new GameSummary(); 21 | gameSummary.clientGesture = Gesture.valueOf(choice.toUpperCase()); 22 | gameSummary.serverGesture = Gesture.ROCK; 23 | 24 | String result = "tie"; 25 | if (gameSummary.clientGesture.equals(Gesture.PAPER)) { 26 | result = "win"; 27 | RestTemplate restTemplate = new RestTemplate(); 28 | restTemplate.postForObject("http://localhost:8080/score/wins", "", Object.class); 29 | } 30 | if (gameSummary.clientGesture.equals(Gesture.SCISSORS)) { 31 | result = "lose"; 32 | RestTemplate restTemplate = new RestTemplate(); 33 | restTemplate.postForObject("http://localhost:8080/score/losses", "", Object.class); 34 | } 35 | if (result == "tie") { 36 | RestTemplate restTemplate = new RestTemplate(); 37 | restTemplate.postForObject("http://localhost:8080/score/ties", "", Object.class); 38 | } 39 | gameSummary.setResult(result); 40 | 41 | RestTemplate restTemplate = new RestTemplate(); 42 | Score score = restTemplate.getForObject("http://localhost:8080/score", Score.class); 43 | 44 | model.addAttribute("gameSummary", gameSummary); 45 | model.addAttribute("score", score); 46 | // request.getRequestDispatcher("index.jsp").forward(request, response); 47 | 48 | return "results"; 49 | } 50 | 51 | @GetMapping("/index") 52 | public String index(@RequestParam(name = "choice", required=false) String choice, Model model) { 53 | return "index"; 54 | } 55 | 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/src/main/resources/META-INF/xxxpersistence.xmlxxx: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | org.hibernate.ejb.HibernatePersistence 9 | 10 | com.mcnz.rps.GameSummary 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://wasadmin.c1wf0kylvvkg.us-east-2.rds.amazonaws.com/wasadmin 2 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 3 | spring.datasource.username=cameronmcnz 4 | spring.datasource.password=85 5 | spring.thymeleaf.enabled=true 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Roshambo! 4 | 5 | 6 | 7 |

Which one will it be?

8 | 9 | rock 10 | paper 11 | scissors 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-mvc-rest-jpa/src/main/resources/templates/results.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Getting Started: Serving Web Content 5 | 6 | 7 | 8 | 9 | rock 10 | paper 11 | scissors 12 | 13 | 14 | 15 |

16 |

17 |

18 | 19 | 20 | -------------------------------------------------------------------------------- /spring-mvc-spring-data-jdbc/.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 | -------------------------------------------------------------------------------- /spring-mvc-spring-data-jdbc/.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 | -------------------------------------------------------------------------------- /spring-mvc-spring-data-jdbc/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.2 9 | 10 | 11 | com.mcnz.rps 12 | Roshambo 13 | 0.0.1-SNAPSHOT 14 | Roshambo 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 17 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-data-jdbc 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-thymeleaf 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-starter-web 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-devtools 49 | runtime 50 | true 51 | 52 | 53 | com.h2database 54 | h2 55 | runtime 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-starter-test 60 | test 61 | 62 | 63 | 64 | 65 | 66 | 67 | org.springframework.boot 68 | spring-boot-maven-plugin 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /spring-mvc-spring-data-jdbc/src/main/java/com/mcnz/rps/RoshamboApplication.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class RoshamboApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(RoshamboApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-mvc-spring-data-jdbc/src/main/java/com/mcnz/rps/Score.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | import org.springframework.data.annotation.Id; 4 | 5 | public class Score { 6 | 7 | @Id 8 | private Integer id; 9 | 10 | private int wins, losses, ties; 11 | 12 | public Score(int wins, int losses, int ties) { 13 | super(); 14 | this.wins = wins; 15 | this.losses = losses; 16 | this.ties = ties; 17 | } 18 | 19 | public int getWins() { 20 | return wins; 21 | } 22 | 23 | public void setWins(int wins) { 24 | this.wins = wins; 25 | } 26 | 27 | public int getLosses() { 28 | return losses; 29 | } 30 | 31 | public void setLosses(int losses) { 32 | this.losses = losses; 33 | } 34 | 35 | public int getTies() { 36 | return ties; 37 | } 38 | 39 | public void setTies(int ties) { 40 | this.ties = ties; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /spring-mvc-spring-data-jdbc/src/main/java/com/mcnz/rps/ScoreRepository.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | 5 | public interface ScoreRepository extends CrudRepository{ 6 | 7 | } 8 | -------------------------------------------------------------------------------- /spring-mvc-spring-data-jdbc/src/main/java/com/mcnz/rps/WebController.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.Model; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | 10 | @Controller 11 | public class WebController { 12 | 13 | @Autowired 14 | public ScoreRepository scoreRepo; 15 | 16 | @ResponseBody 17 | @GetMapping("/score") 18 | public Score getScore(){ 19 | Score score; 20 | try { 21 | score = scoreRepo.findById(new Integer(1)).get(); 22 | } catch (Exception e) { 23 | score = new Score(11, 22, 33); 24 | scoreRepo.save(score); 25 | } 26 | return score; 27 | } 28 | 29 | @GetMapping("/playagame") 30 | public String playGame(@RequestParam(name="choice")String theChoice, Model model) { 31 | 32 | String theOutcome = "tie"; 33 | Score score = this.getScore(); 34 | 35 | if (theChoice.equalsIgnoreCase("rock")) { 36 | score.setTies(score.getTies()+1); 37 | theOutcome = "tie"; 38 | } 39 | if (theChoice.equalsIgnoreCase("paper")) { 40 | score.setWins(score.getWins()+1); 41 | theOutcome = "win"; 42 | } 43 | if (theChoice.equalsIgnoreCase("scissors")) { 44 | score.setLosses(score.getLosses()+1); 45 | theOutcome = "loss"; 46 | } 47 | scoreRepo.save(score); 48 | 49 | model.addAttribute("score", score); 50 | model.addAttribute("theOutcome", theOutcome); 51 | model.addAttribute("yourChoice", theChoice); 52 | return "results"; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /spring-mvc-spring-data-jdbc/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=Roshambo 2 | -------------------------------------------------------------------------------- /spring-mvc-spring-data-jdbc/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE SCORE ( id INTEGER auto_increment NOT NULL, WINS INTEGER NOT NULL, LOSSES INTEGER NOT NULL, TIES INTEGER NOT NULL,PRIMARY KEY (id)) -------------------------------------------------------------------------------- /spring-mvc-spring-data-jdbc/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | This my Roshambo App 4 | 5 | 6 |

What will it be???

7 | rock | 8 | paper | 9 | scissors
10 | 11 | -------------------------------------------------------------------------------- /spring-mvc-spring-data-jdbc/src/main/resources/templates/results.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | Apparently you chose:
7 | 8 | The result of playing the game was:
9 | 10 | Wins: | 11 | Losses | 12 | Ties:
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /spring-mvc-spring-data-jdbc/src/test/java/com/mcnz/rps/RoshamboApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class RoshamboApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-rest/.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 | -------------------------------------------------------------------------------- /spring-rest/.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 | -------------------------------------------------------------------------------- /spring-rest/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 https://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 | -------------------------------------------------------------------------------- /spring-rest/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.1 9 | 10 | 11 | com.mcnz.rps 12 | roshambo 13 | 0.0.1-SNAPSHOT 14 | Roshambo 15 | Roshambo app 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 17 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-devtools 41 | runtime 42 | true 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter-test 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-maven-plugin 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /spring-rest/src/main/java/com/mcnz/rps/GameSummary.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | import java.time.LocalTime; 4 | 5 | public class GameSummary { 6 | 7 | Long id; 8 | 9 | String clientGesture; 10 | String serverGesture; 11 | String result; 12 | LocalTime timestamp = LocalTime.now(); 13 | 14 | public GameSummary(String clientGesture, String serverGesture, String result) { 15 | super(); 16 | this.clientGesture = clientGesture; 17 | this.serverGesture = serverGesture; 18 | this.result = result; 19 | } 20 | 21 | public Long getId() { 22 | return id; 23 | } 24 | 25 | public void setId(Long id) { 26 | this.id = id; 27 | } 28 | 29 | public String getClientGesture() { 30 | return clientGesture; 31 | } 32 | 33 | public void setClientGesture(String clientGesture) { 34 | this.clientGesture = clientGesture; 35 | } 36 | 37 | public String getServerGesture() { 38 | return serverGesture; 39 | } 40 | 41 | public void setServerGesture(String serverGesture) { 42 | this.serverGesture = serverGesture; 43 | } 44 | 45 | public String getResult() { 46 | return result; 47 | } 48 | 49 | public void setResult(String result) { 50 | this.result = result; 51 | } 52 | 53 | public LocalTime getTimestamp() { 54 | return timestamp; 55 | } 56 | 57 | public void setTimestamp(LocalTime timestamp) { 58 | this.timestamp = timestamp; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /spring-rest/src/main/java/com/mcnz/rps/GameSummaryController.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.web.bind.annotation.CrossOrigin; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestBody; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | @CrossOrigin 14 | @RestController("") 15 | public class GameSummaryController { 16 | 17 | static List history = new ArrayList(); 18 | 19 | @GetMapping("/gamesummary") 20 | public List getHistory() { 21 | return history; 22 | } 23 | 24 | 25 | @GetMapping("gamesummary/{id}") 26 | public GameSummary getGameSummary(@PathVariable int id) { 27 | return history.get(id); 28 | } 29 | 30 | @PostMapping("/gamesummary") 31 | public GameSummary addGameSummary(@RequestBody GameSummary gameSummary) { 32 | history.add(gameSummary); 33 | return gameSummary; 34 | } 35 | 36 | 37 | 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-rest/src/main/java/com/mcnz/rps/RoshamboApplication.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class RoshamboApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(RoshamboApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-rest/src/main/java/com/mcnz/rps/Score.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | public class Score { 4 | 5 | int wins; 6 | int losses; 7 | int ties; 8 | 9 | public Score() {} 10 | public Score(int wins, int losses, int ties) { 11 | super(); 12 | this.wins = wins; 13 | this.losses = losses; 14 | this.ties = ties; 15 | } 16 | 17 | public int getWins() { 18 | return wins; 19 | } 20 | public void setWins(int wins) { 21 | this.wins = wins; 22 | } 23 | public int getLosses() { 24 | return losses; 25 | } 26 | public void setLosses(int losses) { 27 | this.losses = losses; 28 | } 29 | public int getTies() { 30 | return ties; 31 | } 32 | public void setTies(int ties) { 33 | this.ties = ties; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-rest/src/main/java/com/mcnz/rps/ScoreController.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | import org.springframework.web.bind.annotation.*; 4 | 5 | 6 | @CrossOrigin 7 | @RestController 8 | public class ScoreController { 9 | 10 | static Score score = new Score(10, 5, 2); 11 | static { 12 | score.wins = 10; 13 | } 14 | 15 | @GetMapping("/score/wins") 16 | public int getWins() { 17 | return score.wins; 18 | } 19 | 20 | @GetMapping("/score/losses") 21 | public int getLosses() { 22 | return score.losses; 23 | } 24 | 25 | @GetMapping("/score/ties") 26 | public int getTies() { 27 | return score.ties; 28 | } 29 | 30 | /* curl localhost:8080/score */ 31 | @GetMapping("/score") 32 | public Score getScore() { 33 | if (score == null) { 34 | score = new Score(); 35 | } 36 | return score; 37 | } 38 | 39 | /* curl -X POST http://localhost:8080/score/wins */ 40 | @PostMapping("/score/wins") 41 | public Score increaseWins() { 42 | score.wins++; 43 | return score; 44 | } 45 | 46 | @PostMapping("/score/losses") 47 | public Score increaseLosses() { 48 | score.losses++; 49 | return score; 50 | } 51 | @PostMapping("/score/ties") 52 | public Score increaseTies() { 53 | score.ties++; 54 | return score; 55 | } 56 | 57 | 58 | /* curl -X PATCH http://localhost:8080/score/wins?new-value=11 */ 59 | @PatchMapping("/score/{winsLossesOrTie}") 60 | public Score setTies(@PathVariable String winsLossesOrTie, @RequestParam(name="new-value") int newValue) { 61 | 62 | if (winsLossesOrTie.equalsIgnoreCase("wins")) { 63 | score.wins = newValue; 64 | } else if (winsLossesOrTie.equalsIgnoreCase("losses")) { 65 | score.losses = newValue; 66 | } else { 67 | score.ties = newValue; 68 | } 69 | return score; 70 | } 71 | 72 | 73 | /* curl -d '{"wins":11, "losses":6, "ties":33}' -H "Content-Type: application/json" -X PUT http://localhost:8080/score */ 74 | @PutMapping("/score") 75 | public Score reset(@RequestBody Score newScore) { 76 | score = newScore; 77 | return score; 78 | } 79 | 80 | /* curl -X DELETE http://localhost:8080/score */ 81 | @DeleteMapping("/score") 82 | public void deleteScore() { 83 | score = null; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /spring-rest/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=Roshambo 2 | -------------------------------------------------------------------------------- /spring-rest/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Rock Paper Scissors!!! 4 | 5 | 6 | 7 | 8 | Which one will it be?
9 | rock 10 | paper 11 | scissors 12 | 13 |
14 |
15 | 16 | 17 | 18 | 19 | 20 | 76 | 77 | 78 | 100 | 101 | 135 | 136 | 202 | 203 | -------------------------------------------------------------------------------- /spring-rest/src/test/java/com/mcnz/rps/RoshamboApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.mcnz.rps; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class RoshamboApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | --------------------------------------------------------------------------------