diff --git a/core-java-11/README.md b/core-java-11/README.md new file mode 100644 index 0000000000..181ada3f45 --- /dev/null +++ b/core-java-11/README.md @@ -0,0 +1,5 @@ +### Relevant articles + +- [Java 11 Single File Source Code](https://www.baeldung.com/java-single-file-source-code) +- [Java 11 Local Variable Syntax for Lambda Parameters](https://www.baeldung.com/java-var-lambda-params) + diff --git a/mvn-wrapper/.gitignore b/mvn-wrapper/.gitignore deleted file mode 100644 index 2af7cefb0a..0000000000 --- a/mvn-wrapper/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -nbproject/private/ -build/ -nbbuild/ -dist/ -nbdist/ -.nb-gradle/ \ No newline at end of file diff --git a/mvn-wrapper/.mvn/wrapper/maven-wrapper.jar b/mvn-wrapper/.mvn/wrapper/maven-wrapper.jar deleted file mode 100755 index f775b1c04c..0000000000 Binary files a/mvn-wrapper/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/mvn-wrapper/.mvn/wrapper/maven-wrapper.properties b/mvn-wrapper/.mvn/wrapper/maven-wrapper.properties deleted file mode 100755 index a447c9fa81..0000000000 --- a/mvn-wrapper/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1 +0,0 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip \ No newline at end of file diff --git a/mvn-wrapper/README.md b/mvn-wrapper/README.md deleted file mode 100644 index bd299d41ed..0000000000 --- a/mvn-wrapper/README.md +++ /dev/null @@ -1,22 +0,0 @@ -Setting up the Maven Wrapper on an Application -============================================== - -This is the code that shows the configurations of maven wrapper on a SpringBoot project. - -### Requirements - -- Maven -- JDK 7 - -### Running - -To build and start the server simply type - -```bash -$ ./mvn clean install -$ ./mvn spring-boot:run -``` - -Now with default configurations it will be available at: [http://localhost:8080](http://localhost:8080) - -Enjoy it :) \ No newline at end of file diff --git a/mvn-wrapper/mvnw b/mvn-wrapper/mvnw deleted file mode 100755 index e96ccd5fbb..0000000000 --- a/mvn-wrapper/mvnw +++ /dev/null @@ -1,227 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvn-wrapper/mvnw.cmd b/mvn-wrapper/mvnw.cmd deleted file mode 100755 index 4f0b068a03..0000000000 --- a/mvn-wrapper/mvnw.cmd +++ /dev/null @@ -1,145 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% diff --git a/mvn-wrapper/pom.xml b/mvn-wrapper/pom.xml deleted file mode 100644 index 7f45fe218d..0000000000 --- a/mvn-wrapper/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - 4.0.0 - mvn-wrapper - 0.0.1-SNAPSHOT - jar - mvn-wrapper - Setting up the Maven Wrapper - - - parent-boot-1 - com.baeldung - 0.0.1-SNAPSHOT - ../parent-boot-1 - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/mvn-wrapper/src/main/java/com/baeldung/MvnWrapperApplication.java b/mvn-wrapper/src/main/java/com/baeldung/MvnWrapperApplication.java deleted file mode 100644 index 3007d24ed0..0000000000 --- a/mvn-wrapper/src/main/java/com/baeldung/MvnWrapperApplication.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class MvnWrapperApplication { - public static void main(String[] args) { - SpringApplication.run(MvnWrapperApplication.class, args); - } -} diff --git a/mvn-wrapper/src/main/resources/logback.xml b/mvn-wrapper/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/mvn-wrapper/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/parent-boot-1/README.md b/parent-boot-1/README.md new file mode 100644 index 0000000000..8b312c348a --- /dev/null +++ b/parent-boot-1/README.md @@ -0,0 +1,2 @@ + +This is a parent module for all projects using Spring Boot 1. diff --git a/parent-boot-2/README.md b/parent-boot-2/README.md index ff12555376..3f18bdf38e 100644 --- a/parent-boot-2/README.md +++ b/parent-boot-2/README.md @@ -1 +1,2 @@ -## Relevant articles: + +This is a parent module for all projects using Spring Boot 2. diff --git a/parent-kotlin/README.md b/parent-kotlin/README.md new file mode 100644 index 0000000000..6c17a6ac29 --- /dev/null +++ b/parent-kotlin/README.md @@ -0,0 +1,2 @@ + +Parent module for Kotlin projects. diff --git a/persistence-modules/spring-boot-persistence-mongodb/README.md b/persistence-modules/spring-boot-persistence-mongodb/README.md new file mode 100644 index 0000000000..f093d4baf0 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-mongodb/README.md @@ -0,0 +1,3 @@ +# Relevant Articles + +- [Auto-Generated Field for MongoDB using Spring Boot](https://www.baeldung.com/spring-boot-mongodb-auto-generated-field) diff --git a/persistence-modules/spring-data-cassandra-reactive/README.md b/persistence-modules/spring-data-cassandra-reactive/README.md new file mode 100644 index 0000000000..87a61d46b3 --- /dev/null +++ b/persistence-modules/spring-data-cassandra-reactive/README.md @@ -0,0 +1,3 @@ +#Relevant Articles + +- [Spring Data with Reactive Cassandra](https://www.baeldung.com/spring-data-cassandra-reactive) diff --git a/pom.xml b/pom.xml index f22aeea5e6..2a3102880a 100644 --- a/pom.xml +++ b/pom.xml @@ -486,7 +486,6 @@ msf4j mustache - mvn-wrapper mybatis noexception @@ -674,7 +673,6 @@ spring-mobile spring-mockito - spring-mustache spring-mvc-forms-jsp spring-mvc-forms-thymeleaf spring-mvc-java @@ -683,7 +681,6 @@ spring-mvc-velocity spring-mvc-webflow spring-mvc-xml - spring-mybatis spring-protobuf @@ -694,7 +691,6 @@ spring-remoting spring-rest spring-rest-angular - spring-rest-embedded-tomcat spring-rest-full spring-rest-hal-browser spring-rest-query-language @@ -752,7 +748,6 @@ spring-zuul - sse-jaxrs static-analysis stripe structurizr @@ -903,7 +898,6 @@ spring-remoting/remoting-rmi/remoting-rmi-server spring-rest spring-rest-angular - spring-rest-embedded-tomcat spring-rest-full spring-rest-simple spring-resttemplate @@ -1196,7 +1190,6 @@ msf4j mustache - mvn-wrapper mybatis noexception @@ -1380,7 +1373,6 @@ spring-mobile spring-mockito - spring-mustache spring-mvc-forms-jsp spring-mvc-forms-thymeleaf spring-mvc-java @@ -1389,7 +1381,6 @@ spring-mvc-velocity spring-mvc-webflow spring-mvc-xml - spring-mybatis spring-protobuf @@ -1400,7 +1391,6 @@ spring-remoting spring-rest spring-rest-angular - spring-rest-embedded-tomcat spring-rest-full spring-rest-hal-browser spring-rest-query-language @@ -1458,7 +1448,6 @@ spring-zuul - sse-jaxrs static-analysis stripe structurizr diff --git a/spring-cloud/README.md b/spring-cloud/README.md index dc43bd1a66..eb2e46c3d0 100644 --- a/spring-cloud/README.md +++ b/spring-cloud/README.md @@ -15,19 +15,8 @@ ### Relevant Articles: - [Intro to Spring Cloud Netflix - Hystrix](http://www.baeldung.com/spring-cloud-netflix-hystrix) - [Dockerizing a Spring Boot Application](http://www.baeldung.com/dockerizing-spring-boot-application) -- [Introduction to Spring Cloud Rest Client with Netflix Ribbon](http://www.baeldung.com/spring-cloud-rest-client-with-netflix-ribbon) -- [A Quick Guide to Spring Cloud Consul](http://www.baeldung.com/spring-cloud-consul) -- [An Introduction to Spring Cloud Zookeeper](http://www.baeldung.com/spring-cloud-zookeeper) - [Using a Spring Cloud App Starter](http://www.baeldung.com/using-a-spring-cloud-app-starter) -- [Spring Cloud Connectors and Heroku](http://www.baeldung.com/spring-cloud-heroku) -- [An Example of Load Balancing with Zuul and Eureka](http://www.baeldung.com/zuul-load-balancing) -- [An Intro to Spring Cloud Contract](http://www.baeldung.com/spring-cloud-contract) - [Using a Spring Cloud App Starter](http://www.baeldung.com/spring-cloud-app-starter) - [Instance Profile Credentials using Spring Cloud](http://www.baeldung.com/spring-cloud-instance-profiles) -- [An Intro to Spring Cloud Security](http://www.baeldung.com/spring-cloud-security) -- [An Intro to Spring Cloud Task](http://www.baeldung.com/spring-cloud-task) - [Running Spring Boot Applications With Minikube](http://www.baeldung.com/spring-boot-minikube) -- [Introduction to Netflix Archaius with Spring Cloud](https://www.baeldung.com/netflix-archaius-spring-cloud-integration) -- [An Intro to Spring Cloud Vault](https://www.baeldung.com/spring-cloud-vault) -- [Netflix Archaius with Various Database Configurations](https://www.baeldung.com/netflix-archaius-database-configurations) -- [Rate Limiting in Spring Cloud Netflix Zuul](https://www.baeldung.com/spring-cloud-zuul-rate-limit) + diff --git a/spring-cloud/spring-cloud-archaius/README.md b/spring-cloud/spring-cloud-archaius/README.md index 9de26352e1..ae853c6ef0 100644 --- a/spring-cloud/spring-cloud-archaius/README.md +++ b/spring-cloud/spring-cloud-archaius/README.md @@ -1,3 +1,8 @@ +# Relevant Articles + +- [Introduction to Netflix Archaius with Spring Cloud](https://www.baeldung.com/netflix-archaius-spring-cloud-integration) +- [Netflix Archaius with Various Database Configurations](https://www.baeldung.com/netflix-archaius-database-configurations) + # Spring Cloud Archaius #### Basic Config @@ -11,4 +16,4 @@ These properties are set up on the main method, since Archaius uses System prope #### Additional Sources In this service we create a new AbstractConfiguration bean, setting up a new Configuration Properties source. -These properties have precedence over all the other properties in the Archaius Composite Configuration. \ No newline at end of file +These properties have precedence over all the other properties in the Archaius Composite Configuration. diff --git a/mvn-wrapper/src/main/resources/application.properties b/spring-cloud/spring-cloud-aws/.attach_pid23938 similarity index 100% rename from mvn-wrapper/src/main/resources/application.properties rename to spring-cloud/spring-cloud-aws/.attach_pid23938 diff --git a/spring-cloud/spring-cloud-aws/README.md b/spring-cloud/spring-cloud-aws/README.md index 1340712c7a..36d0c7080e 100644 --- a/spring-cloud/spring-cloud-aws/README.md +++ b/spring-cloud/spring-cloud-aws/README.md @@ -1,5 +1,11 @@ # Spring Cloud AWS +# Relevant Articles +- [Spring Cloud AWS – S3](https://www.baeldung.com/spring-cloud-aws-s3) +- [Spring Cloud AWS – EC2](https://www.baeldung.com/spring-cloud-aws-ec2) +- [Spring Cloud AWS – RDS](https://www.baeldung.com/spring-cloud-aws-rds) +- [Spring Cloud AWS – Messaging Support](https://www.baeldung.com/spring-cloud-aws-messaging) + #### Running the Integration Tests To run the Integration Tests, we need to have an AWS account and have API keys generated for programmatic access. Edit @@ -23,4 +29,4 @@ Multiple application classes are available under this project. To launch Instan ``` com.baeldung.spring.cloud.aws.InstanceProfileAwsApplication -``` \ No newline at end of file +``` diff --git a/spring-cloud/spring-cloud-aws/src/test/resources/test-file-upload.txt b/spring-cloud/spring-cloud-aws/src/test/resources/test-file-upload.txt new file mode 100644 index 0000000000..7c4a013e52 --- /dev/null +++ b/spring-cloud/spring-cloud-aws/src/test/resources/test-file-upload.txt @@ -0,0 +1 @@ +aaa \ No newline at end of file diff --git a/spring-cloud/spring-cloud-connectors-heroku/README.md b/spring-cloud/spring-cloud-connectors-heroku/README.md new file mode 100644 index 0000000000..7c58d2526f --- /dev/null +++ b/spring-cloud/spring-cloud-connectors-heroku/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Spring Cloud Connectors and Heroku](http://www.baeldung.com/spring-cloud-heroku) diff --git a/spring-cloud/spring-cloud-consul/README.md b/spring-cloud/spring-cloud-consul/README.md new file mode 100644 index 0000000000..47dc39f0d5 --- /dev/null +++ b/spring-cloud/spring-cloud-consul/README.md @@ -0,0 +1,3 @@ + +### Relevant Articles: +- [A Quick Guide to Spring Cloud Consul](http://www.baeldung.com/spring-cloud-consul) diff --git a/spring-cloud/spring-cloud-contract/README.md b/spring-cloud/spring-cloud-contract/README.md new file mode 100644 index 0000000000..70e056757b --- /dev/null +++ b/spring-cloud/spring-cloud-contract/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [An Intro to Spring Cloud Contract](http://www.baeldung.com/spring-cloud-contract) diff --git a/spring-cloud/spring-cloud-kubernetes/README.md b/spring-cloud/spring-cloud-kubernetes/README.md new file mode 100644 index 0000000000..295ead1c2f --- /dev/null +++ b/spring-cloud/spring-cloud-kubernetes/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Running Spring Boot Applications With Minikube](https://www.baeldung.com/spring-boot-minikube) diff --git a/spring-cloud/spring-cloud-rest/README.md b/spring-cloud/spring-cloud-rest/README.md new file mode 100644 index 0000000000..a650004708 --- /dev/null +++ b/spring-cloud/spring-cloud-rest/README.md @@ -0,0 +1,2 @@ + +Code for an ebook - "A REST API with Spring Boot and Spring Cloud" diff --git a/spring-cloud/spring-cloud-ribbon-client/README.md b/spring-cloud/spring-cloud-ribbon-client/README.md new file mode 100644 index 0000000000..596b3226c8 --- /dev/null +++ b/spring-cloud/spring-cloud-ribbon-client/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Introduction to Spring Cloud Rest Client with Netflix Ribbon](http://www.baeldung.com/spring-cloud-rest-client-with-netflix-ribbon) diff --git a/spring-cloud/spring-cloud-security/README.md b/spring-cloud/spring-cloud-security/README.md new file mode 100644 index 0000000000..7099406614 --- /dev/null +++ b/spring-cloud/spring-cloud-security/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [An Intro to Spring Cloud Security](http://www.baeldung.com/spring-cloud-security) diff --git a/spring-cloud/spring-cloud-task/README.md b/spring-cloud/spring-cloud-task/README.md new file mode 100644 index 0000000000..cabc1ac854 --- /dev/null +++ b/spring-cloud/spring-cloud-task/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [An Intro to Spring Cloud Task](http://www.baeldung.com/spring-cloud-task) diff --git a/spring-cloud/spring-cloud-vault/README.md b/spring-cloud/spring-cloud-vault/README.md new file mode 100644 index 0000000000..b7529b4a5c --- /dev/null +++ b/spring-cloud/spring-cloud-vault/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: +- [An Intro to Spring Cloud Vault](https://www.baeldung.com/spring-cloud-vault) + diff --git a/spring-cloud/spring-cloud-zookeeper/README.md b/spring-cloud/spring-cloud-zookeeper/README.md new file mode 100644 index 0000000000..a639833452 --- /dev/null +++ b/spring-cloud/spring-cloud-zookeeper/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [An Introduction to Spring Cloud Zookeeper](http://www.baeldung.com/spring-cloud-zookeeper) diff --git a/spring-cloud/spring-cloud-zuul-eureka-integration/README.md b/spring-cloud/spring-cloud-zuul-eureka-integration/README.md new file mode 100644 index 0000000000..32074f3699 --- /dev/null +++ b/spring-cloud/spring-cloud-zuul-eureka-integration/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [An Example of Load Balancing with Zuul and Eureka](http://www.baeldung.com/zuul-load-balancing) diff --git a/spring-cloud/spring-cloud-zuul/README.md b/spring-cloud/spring-cloud-zuul/README.md new file mode 100644 index 0000000000..834917f159 --- /dev/null +++ b/spring-cloud/spring-cloud-zuul/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Rate Limiting in Spring Cloud Netflix Zuul](https://www.baeldung.com/spring-cloud-zuul-rate-limit) diff --git a/spring-mustache/.gitignore b/spring-mustache/.gitignore deleted file mode 100644 index 2af7cefb0a..0000000000 --- a/spring-mustache/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -nbproject/private/ -build/ -nbbuild/ -dist/ -nbdist/ -.nb-gradle/ \ No newline at end of file diff --git a/spring-mustache/README.md b/spring-mustache/README.md deleted file mode 100644 index ff12555376..0000000000 --- a/spring-mustache/README.md +++ /dev/null @@ -1 +0,0 @@ -## Relevant articles: diff --git a/spring-mustache/pom.xml b/spring-mustache/pom.xml deleted file mode 100644 index 9e4c528ee0..0000000000 --- a/spring-mustache/pom.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - 4.0.0 - - spring-mustache - jar - spring-mustache - Demo project for Spring Boot - - - parent-boot-1 - com.baeldung - 0.0.1-SNAPSHOT - ../parent-boot-1 - - - - - org.springframework.boot - spring-boot-starter-mustache - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.webjars - bootstrap - ${bootstrap.version} - - - org.fluttercode.datafactory - datafactory - ${datafactory.version} - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - 3.3.7 - 0.8 - - - diff --git a/spring-mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java b/spring-mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java deleted file mode 100644 index 8cdf89d08a..0000000000 --- a/spring-mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.springmustache; - -import com.samskivert.mustache.Mustache; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.mustache.MustacheEnvironmentCollector; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.core.env.Environment; - -@SpringBootApplication -@ComponentScan(basePackages = {"com.baeldung"}) -public class SpringMustacheApplication { - - public static void main(String[] args) { - SpringApplication.run(SpringMustacheApplication.class, args); - } - - @Bean - public Mustache.Compiler mustacheCompiler(Mustache.TemplateLoader templateLoader, Environment environment) { - - MustacheEnvironmentCollector collector = new MustacheEnvironmentCollector(); - collector.setEnvironment(environment); - - return Mustache.compiler() - .defaultValue("Some Default Value") - .withLoader(templateLoader) - .withCollector(collector); - - } -} - diff --git a/spring-mustache/src/main/java/com/baeldung/springmustache/controller/ArticleController.java b/spring-mustache/src/main/java/com/baeldung/springmustache/controller/ArticleController.java deleted file mode 100644 index 5fc34c9f07..0000000000 --- a/spring-mustache/src/main/java/com/baeldung/springmustache/controller/ArticleController.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.baeldung.springmustache.controller; - -import com.baeldung.springmustache.model.Article; -import org.fluttercode.datafactory.impl.DataFactory; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.servlet.ModelAndView; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -@Controller -public class ArticleController { - - @GetMapping("/article") - public ModelAndView displayArticle(Map model) { - - List
articles = IntStream.range(0, 10) - .mapToObj(i -> generateArticle("Article Title " + i)) - .collect(Collectors.toList()); - - Map modelMap = new HashMap<>(); - modelMap.put("articles", articles); - - return new ModelAndView("index", modelMap); - } - - private Article generateArticle(String title) { - Article article = new Article(); - DataFactory factory = new DataFactory(); - article.setTitle(title); - article.setBody( - "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur faucibus tempor diam. In molestie arcu eget ante facilisis sodales. Maecenas porta tellus sapien, eget rutrum nisi blandit in. Mauris tempor auctor ante, ut blandit velit venenatis id. Ut varius, augue aliquet feugiat congue, arcu ipsum finibus purus, dapibus semper velit sapien venenatis magna. Nunc quam ex, aliquet at rutrum sed, vestibulum quis libero. In laoreet libero cursus maximus vulputate. Nullam in fermentum sem. Duis aliquam ullamcorper dui, et dictum justo placerat id. Aliquam pretium orci quis sapien convallis, non blandit est tempus."); - article.setPublishDate(factory.getBirthDate().toString()); - article.setAuthor(factory.getName()); - return article; - } -} - - diff --git a/spring-mustache/src/main/java/com/baeldung/springmustache/model/Article.java b/spring-mustache/src/main/java/com/baeldung/springmustache/model/Article.java deleted file mode 100644 index 78b08f877f..0000000000 --- a/spring-mustache/src/main/java/com/baeldung/springmustache/model/Article.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.baeldung.springmustache.model; - -public class Article { - private String title; - private String body; - private String author; - private String publishDate; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getBody() { - return body; - } - - public void setBody(String body) { - this.body = body; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public String getPublishDate() { - return publishDate; - } - - public void setPublishDate(String publishDate) { - this.publishDate = publishDate; - } - -} diff --git a/spring-mustache/src/main/resources/application.properties b/spring-mustache/src/main/resources/application.properties deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-mustache/src/main/resources/logback.xml b/spring-mustache/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/spring-mustache/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/spring-mustache/src/main/resources/templates/error/error.html b/spring-mustache/src/main/resources/templates/error/error.html deleted file mode 100644 index fa29db41c4..0000000000 --- a/spring-mustache/src/main/resources/templates/error/error.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - Something went wrong: {{status}} {{error}} - - - \ No newline at end of file diff --git a/spring-mustache/src/main/resources/templates/index.html b/spring-mustache/src/main/resources/templates/index.html deleted file mode 100644 index bda60f9d8f..0000000000 --- a/spring-mustache/src/main/resources/templates/index.html +++ /dev/null @@ -1,9 +0,0 @@ -{{>layout/header}} - -
{{>layout/article}}
- - - - -{{>layout/footer}} diff --git a/spring-mustache/src/main/resources/templates/layout/article.html b/spring-mustache/src/main/resources/templates/layout/article.html deleted file mode 100644 index 9d573580d3..0000000000 --- a/spring-mustache/src/main/resources/templates/layout/article.html +++ /dev/null @@ -1,8 +0,0 @@ -
- {{#articles}} -

{{title}}

-

{{publishDate}}

-

{{author}}

-

{{body}}

- {{/articles}} -
\ No newline at end of file diff --git a/spring-mustache/src/main/resources/templates/layout/footer.html b/spring-mustache/src/main/resources/templates/layout/footer.html deleted file mode 100644 index 04f34cac54..0000000000 --- a/spring-mustache/src/main/resources/templates/layout/footer.html +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/spring-mustache/src/main/resources/templates/layout/header.html b/spring-mustache/src/main/resources/templates/layout/header.html deleted file mode 100644 index d203ef800b..0000000000 --- a/spring-mustache/src/main/resources/templates/layout/header.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/spring-mustache/src/test/java/com/baeldung/springmustache/SpringMustacheApplicationIntegrationTest.java b/spring-mustache/src/test/java/com/baeldung/springmustache/SpringMustacheApplicationIntegrationTest.java deleted file mode 100644 index 1eecf58986..0000000000 --- a/spring-mustache/src/test/java/com/baeldung/springmustache/SpringMustacheApplicationIntegrationTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baeldung.springmustache; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class SpringMustacheApplicationIntegrationTest { - - @Autowired - private TestRestTemplate restTemplate; - - @Test - public void givenIndexPageWhenContainsArticleThenTrue() { - - ResponseEntity entity = this.restTemplate.getForEntity("/article", String.class); - - Assert.assertTrue(entity.getStatusCode().equals(HttpStatus.OK)); - Assert.assertTrue(entity.getBody().contains("Article Title 0")); - } - -} diff --git a/spring-mybatis/README.md b/spring-mybatis/README.md deleted file mode 100644 index ff12555376..0000000000 --- a/spring-mybatis/README.md +++ /dev/null @@ -1 +0,0 @@ -## Relevant articles: diff --git a/spring-mybatis/pom.xml b/spring-mybatis/pom.xml deleted file mode 100644 index af70cb6377..0000000000 --- a/spring-mybatis/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - 4.0.0 - com.baeldung - spring-mybatis - jar - 0.0.1-SNAPSHOT - spring-mybatis - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - - - - - org.mybatis - mybatis - ${mybatis.version} - - - org.mybatis - mybatis-spring - ${mybatis-spring.version} - - - org.springframework - spring-context-support - ${spring.version} - - - org.springframework - spring-test - ${spring.version} - test - - - mysql - mysql-connector-java - ${mysql-connector.version} - - - javax.servlet - jstl - ${jstl.version} - - - org.springframework - spring-webmvc - ${spring-webmvc.version} - - - javax.servlet - servlet-api - ${servlet.version} - - - - - spring-mybatis - - - - 3.1.1 - 1.1.1 - 3.1.1.RELEASE - 3.2.4.RELEASE - 5.1.40 - 1.2 - 2.5 - - diff --git a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/application/SpringMyBatisApplication.java b/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/application/SpringMyBatisApplication.java deleted file mode 100644 index acfaff2669..0000000000 --- a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/application/SpringMyBatisApplication.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.baeldung.spring.mybatis.application; - -import java.util.Date; - -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import com.baeldung.spring.mybatis.model.Student; -import com.baeldung.spring.mybatis.service.StudentService; - -public class SpringMyBatisApplication { - - public static void main(String[] args){ - ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("mybatis-spring.xml"); - - StudentService studentService = (StudentService) ctx.getBean("studentService"); - Student student = new Student(); - student.setFirstName("Santosh"); - student.setLastName("B S"); - student.setEmailAddress("santosh.bse@gmail.com"); - student.setPassword("Test123"); - student.setDateOfBirth(new Date()); - student.setUserName("santoshbs1"); - - boolean result = studentService.insertStudent(student); - if(result){ - System.out.println("Student record saved successfully"); - } - else{ - System.out.println("Encountered an error while saving student data"); - } - - final String userName = "santosh"; - Student matchingStudent = studentService.getStudentByUserName(userName); - if(matchingStudent == null){ - System.out.println("No matching student found for User Name - " + userName); - } - else{ - System.out.println("Student Details are as follows : "); - System.out.println("First Name : " + matchingStudent.getFirstName()); - System.out.println("Last Name : " + matchingStudent.getLastName()); - System.out.println("EMail : " + matchingStudent.getEmailAddress()); - System.out.println("DOB : " + matchingStudent.getDateOfBirth()); - System.out.println("User Name : " + matchingStudent.getUserName()); - } - - } - -} diff --git a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/controller/StudentController.java b/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/controller/StudentController.java deleted file mode 100644 index c1e5579103..0000000000 --- a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/controller/StudentController.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.baeldung.spring.mybatis.controller; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.ui.ModelMap; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.SessionAttributes; - -import com.baeldung.spring.mybatis.model.Student; -import com.baeldung.spring.mybatis.model.StudentLogin; -import com.baeldung.spring.mybatis.service.StudentService; - -@Controller -@SessionAttributes("student") -public class StudentController { - - @Autowired - private StudentService studentService; - - @RequestMapping(value = "/signup", method = RequestMethod.GET) - public String signup(Model model) { - Student student = new Student(); - model.addAttribute("student", student); - return "signup"; - } - - @RequestMapping(value = "/signup", method = RequestMethod.POST) - public String signup(@Validated @ModelAttribute("student") Student student, BindingResult result, ModelMap model) { - if (studentService.getStudentByUserName(student.getUserName()) != null) { - model.addAttribute("message", "User Name exists. Try another user name"); - return "signup"; - } else { - studentService.insertStudent(student); - model.addAttribute("message", "Saved student details"); - return "redirect:login.html"; - } - } - - @RequestMapping(value = "/login", method = RequestMethod.GET) - public String login(Model model) { - StudentLogin studentLogin = new StudentLogin(); - model.addAttribute("studentLogin", studentLogin); - return "login"; - } - - @RequestMapping(value = "/login", method = RequestMethod.POST) - public String login(@ModelAttribute("studentLogin") StudentLogin studentLogin, BindingResult result, ModelMap model) { - boolean found = studentService.getStudentByLogin(studentLogin.getUserName(), studentLogin.getPassword()) != null; - if (found) { - return "success"; - } else { - return "failure"; - } - } -} \ No newline at end of file diff --git a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/mappers/StudentMapper.java b/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/mappers/StudentMapper.java deleted file mode 100644 index cf3584f7b1..0000000000 --- a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/mappers/StudentMapper.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.spring.mybatis.mappers; - -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Options; -import org.apache.ibatis.annotations.Select; - -import com.baeldung.spring.mybatis.model.Student; - -public interface StudentMapper { - @Insert("INSERT INTO student(userName, password, firstName,lastName, dateOfBirth, emailAddress) VALUES" - + "(#{userName},#{password}, #{firstName}, #{lastName}, #{dateOfBirth}, #{emailAddress})") - @Options(useGeneratedKeys = true, keyProperty = "id", flushCache = true, keyColumn = "id") - public void insertStudent(Student student); - - @Select("SELECT USERNAME as userName, PASSWORD as password, FIRSTNAME as firstName, LASTNAME as lastName, " - + "DATEOFBIRTH as dateOfBirth, EMAILADDRESS as emailAddress " + "FROM student WHERE userName = #{userName}") - public Student getStudentByUserName(String userName); - -} \ No newline at end of file diff --git a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/model/Student.java b/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/model/Student.java deleted file mode 100644 index f33dd44f72..0000000000 --- a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/model/Student.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.baeldung.spring.mybatis.model; - -import java.util.Date; - -public class Student { - private Long id; - private String userName; - private String firstName; - private String lastName; - private String password; - private String emailAddress; - private Date dateOfBirth; - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - public String getUserName() { - return userName; - } - public void setUserName(String userName) { - this.userName = userName; - } - public String getFirstName() { - return firstName; - } - public void setFirstName(String firstName) { - this.firstName = firstName; - } - public String getLastName() { - return lastName; - } - public void setLastName(String lastName) { - this.lastName = lastName; - } - public String getPassword() { - return password; - } - public void setPassword(String password) { - this.password = password; - } - public String getEmailAddress() { - return emailAddress; - } - public void setEmailAddress(String emailAddress) { - this.emailAddress = emailAddress; - } - public Date getDateOfBirth() { - return dateOfBirth; - } - public void setDateOfBirth(Date dateOfBirth) { - this.dateOfBirth = dateOfBirth; - } -} diff --git a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/model/StudentLogin.java b/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/model/StudentLogin.java deleted file mode 100644 index 867857b510..0000000000 --- a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/model/StudentLogin.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.spring.mybatis.model; - -public class StudentLogin { - private String userName; - private String password; - public String getUserName() { - return userName; - } - public void setUserName(String userName) { - this.userName = userName; - } - public String getPassword() { - return password; - } - public void setPassword(String password) { - this.password = password; - } -} diff --git a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/service/StudentService.java b/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/service/StudentService.java deleted file mode 100644 index d26115beee..0000000000 --- a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/service/StudentService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.spring.mybatis.service; - -import com.baeldung.spring.mybatis.model.Student; - -public interface StudentService { - public boolean insertStudent(Student student); - public Student getStudentByLogin(String userName, String password); - public Student getStudentByUserName(String userName); -} \ No newline at end of file diff --git a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/service/StudentServiceImpl.java b/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/service/StudentServiceImpl.java deleted file mode 100644 index 538e650482..0000000000 --- a/spring-mybatis/src/main/java/com/baeldung/spring/mybatis/service/StudentServiceImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.baeldung.spring.mybatis.service; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.baeldung.spring.mybatis.mappers.StudentMapper; -import com.baeldung.spring.mybatis.model.Student; - -@Service("studentService") -public class StudentServiceImpl implements StudentService { - - @Autowired - private StudentMapper studentMapper; - - @Transactional - public boolean insertStudent(Student student) { - boolean result=false; - try{ - studentMapper.insertStudent(student); - result = true; - } - catch(Exception ex){ - ex.printStackTrace(); - result = false; - } - return result; - } - - public Student getStudentByLogin(String userName, String password) { - Student student = studentMapper.getStudentByUserName(userName); - return student; - } - - public Student getStudentByUserName(String userName) { - Student student = studentMapper.getStudentByUserName(userName); - return student; - } - -} diff --git a/spring-mybatis/src/main/resources/logback.xml b/spring-mybatis/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/spring-mybatis/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/spring-mybatis/src/main/resources/mybatis-spring.xml b/spring-mybatis/src/main/resources/mybatis-spring.xml deleted file mode 100644 index 9f5bab3247..0000000000 --- a/spring-mybatis/src/main/resources/mybatis-spring.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-mybatis/src/main/webapp/WEB-INF/conf/mybatis-spring.xml b/spring-mybatis/src/main/webapp/WEB-INF/conf/mybatis-spring.xml deleted file mode 100644 index c8b686358c..0000000000 --- a/spring-mybatis/src/main/webapp/WEB-INF/conf/mybatis-spring.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-mybatis/src/main/webapp/WEB-INF/jsp/failure.jsp b/spring-mybatis/src/main/webapp/WEB-INF/jsp/failure.jsp deleted file mode 100644 index 66f16d4e09..0000000000 --- a/spring-mybatis/src/main/webapp/WEB-INF/jsp/failure.jsp +++ /dev/null @@ -1,36 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> - - - - - -Login Failure - - - - -
- Login     Signup -
-
-
-

Student Enrollment Login failure

-
-
-
- - Oh snap! Something is wrong. Change a few things up - and try submitting again. -
-
-
-
-
- - ">Try - again? - - \ No newline at end of file diff --git a/spring-mybatis/src/main/webapp/WEB-INF/jsp/login.jsp b/spring-mybatis/src/main/webapp/WEB-INF/jsp/login.jsp deleted file mode 100644 index 5a895bb348..0000000000 --- a/spring-mybatis/src/main/webapp/WEB-INF/jsp/login.jsp +++ /dev/null @@ -1,81 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> -<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> - - - - - - - -Student Login - - -
- Login     Signup -
- -
-
-
-

Welcome to Online Student Enrollment Application

-

Login to explore the complete features!

-
-
- -
-
- -
-
- Student Enrollment Login Form - - - - - - - - - - - - - - - -
-
- -      - -
- -
-
-
- - - - \ No newline at end of file diff --git a/spring-mybatis/src/main/webapp/WEB-INF/jsp/signup.jsp b/spring-mybatis/src/main/webapp/WEB-INF/jsp/signup.jsp deleted file mode 100644 index bc628862f3..0000000000 --- a/spring-mybatis/src/main/webapp/WEB-INF/jsp/signup.jsp +++ /dev/null @@ -1,130 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> - -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> - - - - - -Student Signup - - - - - -
- Login     Signup -
- -
-
-
-

Welcome to Online Student Enrollment Application

-

Login to explore the complete features!

-
-
- -
-
- -
- -
${message}
-
-
- -
- -
- Student Enrollment Signup Form - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- -     - -
-
-
-
- - \ No newline at end of file diff --git a/spring-mybatis/src/main/webapp/WEB-INF/jsp/success.jsp b/spring-mybatis/src/main/webapp/WEB-INF/jsp/success.jsp deleted file mode 100644 index 7ae37bc241..0000000000 --- a/spring-mybatis/src/main/webapp/WEB-INF/jsp/success.jsp +++ /dev/null @@ -1,35 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> - - - - -Login Success - - - - -
- Login     Signup -
- -
-
-

Student Enrollment Login success

-
-
-
- - Well done! You successfully logged-into the system. - Now you can explore the complete features! -
-
-
-
-
- ">Login - as different user? - - \ No newline at end of file diff --git a/spring-mybatis/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.40-bin.jar b/spring-mybatis/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.40-bin.jar deleted file mode 100644 index 60bef5cfbf..0000000000 Binary files a/spring-mybatis/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.40-bin.jar and /dev/null differ diff --git a/spring-mybatis/src/main/webapp/WEB-INF/web.xml b/spring-mybatis/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 569b5ef9b1..0000000000 --- a/spring-mybatis/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - myBatisSpringServlet - org.springframework.web.servlet.DispatcherServlet - - contextConfigLocation - /WEB-INF/conf/mybatis-spring.xml - - - - - myBatisSpringServlet - *.html - - - MyBatis-Spring Integration - \ No newline at end of file diff --git a/spring-mybatis/src/main/webapp/index.jsp b/spring-mybatis/src/main/webapp/index.jsp deleted file mode 100644 index b60222e7de..0000000000 --- a/spring-mybatis/src/main/webapp/index.jsp +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - -
- Login     Signup -
- -
-
-
-

Welcome to Online Student Enrollment Application

-

Login to explore the complete features!

-
-
- -
-
- - - \ No newline at end of file diff --git a/spring-rest-embedded-tomcat/pom.xml b/spring-rest-embedded-tomcat/pom.xml deleted file mode 100644 index a8c53dbc3a..0000000000 --- a/spring-rest-embedded-tomcat/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ - - 4.0.0 - org.baeldung.embedded - spring-rest-embedded-tomcat - spring-rest-embedded-tomcat - war - - - com.baeldung - parent-spring-5 - 0.0.1-SNAPSHOT - ../parent-spring-5 - - - - - org.springframework - spring-webmvc - ${spring.version} - - - - javax.servlet - javax.servlet-api - ${servlet.version} - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.library} - - - - org.apache.tomcat.embed - tomcat-embed-core - ${tomcat.version} - test - - - - org.apache.tomcat - tomcat-jasper - ${tomcat.version} - test - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - - - - org.springframework.boot - spring-boot-starter-test - 1.5.10.RELEASE - test - - - - - - 2.9.2 - 4.0.0 - 9.0.1 - 4.5.3 - 4.4.8 - false - - - \ No newline at end of file diff --git a/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/configuration/AppInitializer.java b/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/configuration/AppInitializer.java deleted file mode 100644 index 24bd28166b..0000000000 --- a/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/configuration/AppInitializer.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.baeldung.embedded.configuration; - -import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; - -public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { - - @Override - protected Class[] getRootConfigClasses() { - return new Class[] { UserConfiguration.class }; - } - - @Override - protected Class[] getServletConfigClasses() { - return null; - } - - @Override - protected String[] getServletMappings() { - return new String[] { "/" }; - } - -} diff --git a/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/configuration/UserConfiguration.java b/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/configuration/UserConfiguration.java deleted file mode 100644 index 4c102a74cb..0000000000 --- a/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/configuration/UserConfiguration.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.baeldung.embedded.configuration; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; - -@Configuration -@EnableWebMvc -@ComponentScan(basePackages = "org.baeldung.embedded") -public class UserConfiguration { - -} diff --git a/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/controller/UserController.java b/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/controller/UserController.java deleted file mode 100644 index a9a5faa0c6..0000000000 --- a/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/controller/UserController.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.baeldung.embedded.controller; - -import org.baeldung.embedded.domain.User; -import org.baeldung.embedded.service.UserService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class UserController { - - @Autowired - UserService userService; - - @RequestMapping("/") - public String welcome() { - return "Hello World!"; - } - - @RequestMapping(method = RequestMethod.GET, value = "/user/{userName}") - @ResponseBody - public User user(@PathVariable String userName) { - return this.userService.getUser(userName); - } -} diff --git a/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/domain/User.java b/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/domain/User.java deleted file mode 100644 index 2f9443daea..0000000000 --- a/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/domain/User.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.baeldung.embedded.domain; - -public class User { - - private String name; - private String hobby; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getHobby() { - return hobby; - } - - public void setHobby(String hobby) { - this.hobby = hobby; - } -} diff --git a/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/service/UserService.java b/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/service/UserService.java deleted file mode 100644 index 76696e12c2..0000000000 --- a/spring-rest-embedded-tomcat/src/main/java/org/baeldung/embedded/service/UserService.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.baeldung.embedded.service; - -import java.util.ArrayList; -import java.util.List; - -import org.baeldung.embedded.domain.User; -import org.springframework.stereotype.Service; - -@Service -public class UserService { - private List users = new ArrayList<>(); - - public void addUser(String name) { - User user = new User(); - user.setName(name); - if (name == "HarryPotter") { - user.setHobby("Quidditch"); - } else { - user.setHobby("MuggleActivity"); - } - users.add(user); - } - - public User getUser(String name) { - for (User user : users) { - if (user.getName() - .equalsIgnoreCase(name)) { - return user; - } - } - - User user = new User(); - user.setName(name); - user.setHobby("None"); - - return user; - } -} diff --git a/spring-rest-embedded-tomcat/src/main/resources/logback.xml b/spring-rest-embedded-tomcat/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/spring-rest-embedded-tomcat/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/spring-rest-embedded-tomcat/src/main/webapp/emptyFile b/spring-rest-embedded-tomcat/src/main/webapp/emptyFile deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-rest-embedded-tomcat/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-rest-embedded-tomcat/src/test/java/org/baeldung/SpringContextIntegrationTest.java deleted file mode 100644 index 8b8ff1a322..0000000000 --- a/spring-rest-embedded-tomcat/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.baeldung; - -import org.baeldung.embedded.configuration.UserConfiguration; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { UserConfiguration.class }) -@WebAppConfiguration -public class SpringContextIntegrationTest { - - @Test - public void whenSpringContextIsBootstrapped_thenNoExceptions() { - } -} diff --git a/spring-rest-embedded-tomcat/src/test/java/org/baeldung/embedded/EmbeddedTomcatApp.java b/spring-rest-embedded-tomcat/src/test/java/org/baeldung/embedded/EmbeddedTomcatApp.java deleted file mode 100644 index f340f6c837..0000000000 --- a/spring-rest-embedded-tomcat/src/test/java/org/baeldung/embedded/EmbeddedTomcatApp.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.baeldung.embedded; - -import java.io.File; -import java.util.concurrent.CountDownLatch; -import org.apache.catalina.Context; -import org.apache.catalina.startup.Tomcat; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.support.WebApplicationContextUtils; - -public class EmbeddedTomcatApp { - - private Tomcat tomcatInstance; - private WebApplicationContext webApplicationContext; - private CountDownLatch started = new CountDownLatch(1); - - public void start() throws Exception { - tomcatInstance = new Tomcat(); - tomcatInstance.setBaseDir(new File(getClass().getResource(".") - .toURI()).getAbsolutePath()); // Tomcat's temporary directory - tomcatInstance.setPort(0); - - Context webapp = tomcatInstance.addWebapp("", new File("src/main/webapp/").getAbsolutePath()); - - webapp.addLifecycleListener(event -> { - if (event.getType() - .equals("after_stop")) { - started.countDown(); - } else if (event.getType() - .equals("after_start")) { - webApplicationContext = WebApplicationContextUtils - .findWebApplicationContext(webapp.getServletContext()); - - ((ConfigurableListableBeanFactory) webApplicationContext - .getAutowireCapableBeanFactory()).registerSingleton("baseUrl", getBaseUrl()); - - started.countDown(); - } - }); - - tomcatInstance.start(); - started.await(); - } - - public Tomcat getTomcatInstance() { - return this.tomcatInstance; - } - - public String getBaseUrl() { - return String.format("http://localhost:%d%s", getLocalPort(), getWebApplicationContext().getServletContext() - .getContextPath()); - } - - public int getLocalPort() { - return tomcatInstance.getConnector() - .getLocalPort(); - } - - public WebApplicationContext getWebApplicationContext() { - return webApplicationContext; - } - - public boolean isStarted() { - return started.getCount() == 0; - } - - public boolean isStartedSucessfully() { - return webApplicationContext != null; - } -} diff --git a/spring-rest-embedded-tomcat/src/test/java/org/baeldung/embedded/EmbeddedTomcatRunner.java b/spring-rest-embedded-tomcat/src/test/java/org/baeldung/embedded/EmbeddedTomcatRunner.java deleted file mode 100644 index 1bf15556e8..0000000000 --- a/spring-rest-embedded-tomcat/src/test/java/org/baeldung/embedded/EmbeddedTomcatRunner.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.baeldung.embedded; - -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.BlockJUnit4ClassRunner; -import org.junit.runners.model.InitializationError; -import org.junit.runners.model.Statement; - -public class EmbeddedTomcatRunner extends BlockJUnit4ClassRunner { - - public EmbeddedTomcatRunner(Class klass) throws InitializationError { - super(klass); - } - - // use one static Tomcat instance shared across all tests - private static EmbeddedTomcatApp embeddedTomcatApp = new EmbeddedTomcatApp(); - - @Override - protected Statement classBlock(RunNotifier notifier) { - ensureSharedTomcatStarted(); - Statement result = super.classBlock(notifier); - return result; - } - - private void ensureSharedTomcatStarted() { - if (!embeddedTomcatApp.isStarted()) { - try { - embeddedTomcatApp.start(); - } catch (Exception e) { - throw new RuntimeException("Error while starting embedded Tomcat server", e); - } - } - } - - @Override - protected Object createTest() throws Exception { - if (!embeddedTomcatApp.isStartedSucessfully()) { - throw new RuntimeException("Tomcat server not started successfully. Skipping test"); - } - Object testInstance = super.createTest(); - embeddedTomcatApp.getWebApplicationContext() - .getAutowireCapableBeanFactory() - .autowireBean(testInstance); - return testInstance; - } -} \ No newline at end of file diff --git a/spring-rest-embedded-tomcat/src/test/java/org/baeldung/embedded/UserIntegrationTest.java b/spring-rest-embedded-tomcat/src/test/java/org/baeldung/embedded/UserIntegrationTest.java deleted file mode 100644 index 1c5d482171..0000000000 --- a/spring-rest-embedded-tomcat/src/test/java/org/baeldung/embedded/UserIntegrationTest.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.baeldung.embedded; - -import java.io.IOException; -import java.util.Map; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; -import org.baeldung.embedded.service.UserService; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; - -import com.fasterxml.jackson.databind.ObjectMapper; - -@RunWith(EmbeddedTomcatRunner.class) -public class UserIntegrationTest { - - @Autowired - protected String baseUrl; - - @Autowired - private UserService userService; - - private String userName = "HarryPotter"; - - @Before - public void setUp() { - userService.addUser(userName); - } - - @Test - public void givenUserName_whenSendGetForHarryPotter_thenHobbyQuidditch() throws IOException { - String url = baseUrl + "/user/" + userName; - - HttpClient httpClient = HttpClientBuilder.create() - .build(); - HttpGet getUserRequest = new HttpGet(url); - getUserRequest.addHeader("Content-type", "application/json"); - HttpResponse response = httpClient.execute(getUserRequest); - - Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine() - .getStatusCode()); - - HttpEntity responseEntity = response.getEntity(); - - Assert.assertNotNull(responseEntity); - - ObjectMapper mapper = new ObjectMapper(); - String retSrc = EntityUtils.toString(responseEntity); - Map result = mapper.readValue(retSrc, Map.class); - - Assert.assertEquals("Quidditch", result.get("hobby")); - } -} diff --git a/sse-jaxrs/pom.xml b/sse-jaxrs/pom.xml deleted file mode 100644 index 68d1b1bc2b..0000000000 --- a/sse-jaxrs/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - 4.0.0 - com.baeldung.sse - sse-jaxrs - 1.0-SNAPSHOT - sse-jaxrs - pom - - - 1.8 - 1.8 - - - - sse-jaxrs-server - sse-jaxrs-client - - - diff --git a/sse-jaxrs/sse-jaxrs-client/pom.xml b/sse-jaxrs/sse-jaxrs-client/pom.xml deleted file mode 100644 index 15a991bfc0..0000000000 --- a/sse-jaxrs/sse-jaxrs-client/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - 4.0.0 - sse-jaxrs-client - sse-jaxrs-client - - - com.baeldung.sse - sse-jaxrs - 1.0-SNAPSHOT - - - - 3.2.0 - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - singleEvent - - java - - - com.baeldung.sse.jaxrs.client.SseClientApp - - - - broadcast - - java - - - com.baeldung.sse.jaxrs.client.SseClientBroadcastApp - - - - - - - - - - org.apache.cxf - cxf-rt-rs-client - ${cxf-version} - - - org.apache.cxf - cxf-rt-rs-sse - ${cxf-version} - - - - diff --git a/sse-jaxrs/sse-jaxrs-client/src/main/java/com/baeldung/sse/jaxrs/client/SseClientApp.java b/sse-jaxrs/sse-jaxrs-client/src/main/java/com/baeldung/sse/jaxrs/client/SseClientApp.java deleted file mode 100644 index 5d42b3a243..0000000000 --- a/sse-jaxrs/sse-jaxrs-client/src/main/java/com/baeldung/sse/jaxrs/client/SseClientApp.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.baeldung.sse.jaxrs.client; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.sse.InboundSseEvent; -import javax.ws.rs.sse.SseEventSource; -import java.util.function.Consumer; - -public class SseClientApp { - - private static final String url = "http://127.0.0.1:9080/sse-jaxrs-server/sse/stock/prices"; - - public static void main(String... args) throws Exception { - - Client client = ClientBuilder.newClient(); - WebTarget target = client.target(url); - try (SseEventSource eventSource = SseEventSource.target(target).build()) { - - eventSource.register(onEvent, onError, onComplete); - eventSource.open(); - - //Consuming events for one hour - Thread.sleep(60 * 60 * 1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - client.close(); - System.out.println("End"); - } - - // A new event is received - private static Consumer onEvent = (inboundSseEvent) -> { - String data = inboundSseEvent.readData(); - System.out.println(data); - }; - - //Error - private static Consumer onError = (throwable) -> { - throwable.printStackTrace(); - }; - - //Connection close and there is nothing to receive - private static Runnable onComplete = () -> { - System.out.println("Done!"); - }; - -} diff --git a/sse-jaxrs/sse-jaxrs-client/src/main/java/com/baeldung/sse/jaxrs/client/SseClientBroadcastApp.java b/sse-jaxrs/sse-jaxrs-client/src/main/java/com/baeldung/sse/jaxrs/client/SseClientBroadcastApp.java deleted file mode 100644 index 9afc187a6d..0000000000 --- a/sse-jaxrs/sse-jaxrs-client/src/main/java/com/baeldung/sse/jaxrs/client/SseClientBroadcastApp.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.baeldung.sse.jaxrs.client; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.sse.InboundSseEvent; -import javax.ws.rs.sse.SseEventSource; -import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; - -public class SseClientBroadcastApp { - - private static final String subscribeUrl = "http://localhost:9080/sse-jaxrs-server/sse/stock/subscribe"; - - - public static void main(String... args) throws Exception { - - Client client = ClientBuilder.newClient(); - WebTarget target = client.target(subscribeUrl); - try (final SseEventSource eventSource = SseEventSource.target(target) - .reconnectingEvery(5, TimeUnit.SECONDS) - .build()) { - eventSource.register(onEvent, onError, onComplete); - eventSource.open(); - System.out.println("Wainting for incoming event ..."); - - //Consuming events for one hour - Thread.sleep(60 * 60 * 1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - client.close(); - System.out.println("End"); - } - - // A new event is received - private static Consumer onEvent = (inboundSseEvent) -> { - String data = inboundSseEvent.readData(); - System.out.println(data); - }; - - //Error - private static Consumer onError = (throwable) -> { - throwable.printStackTrace(); - }; - - //Connection close and there is nothing to receive - private static Runnable onComplete = () -> { - System.out.println("Done!"); - }; - -} diff --git a/sse-jaxrs/sse-jaxrs-client/src/main/resources/logback.xml b/sse-jaxrs/sse-jaxrs-client/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/sse-jaxrs/sse-jaxrs-client/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/sse-jaxrs/sse-jaxrs-server/pom.xml b/sse-jaxrs/sse-jaxrs-server/pom.xml deleted file mode 100644 index 825dcddbdf..0000000000 --- a/sse-jaxrs/sse-jaxrs-server/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - 4.0.0 - sse-jaxrs-server - war - sse-jaxrs-server - - - com.baeldung.sse - sse-jaxrs - 1.0-SNAPSHOT - - - - 2.4.2 - false - 18.0.0.2 - - - - ${artifactId} - - - net.wasdev.wlp.maven.plugins - liberty-maven-plugin - ${liberty-maven-plugin.version} - - - io.openliberty - openliberty-webProfile8 - ${openliberty-version} - zip - - project - true - src/main/liberty/config/server.xml - - - - install-server - prepare-package - - install-server - create-server - install-feature - - - - install-apps - package - - install-apps - - - - - - - - - - - javax.ws.rs - javax.ws.rs-api - 2.1 - provided - - - javax.enterprise - cdi-api - 2.0 - provided - - - javax.json.bind - javax.json.bind-api - 1.0 - provided - - - - - diff --git a/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/AppConfig.java b/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/AppConfig.java deleted file mode 100644 index 058d19f045..0000000000 --- a/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/AppConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.sse.jaxrs; - -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; - -@ApplicationPath("sse") -public class AppConfig extends Application { -} diff --git a/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/SseResource.java b/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/SseResource.java deleted file mode 100644 index 1f60168a1b..0000000000 --- a/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/SseResource.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.baeldung.sse.jaxrs; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.sse.OutboundSseEvent; -import javax.ws.rs.sse.Sse; -import javax.ws.rs.sse.SseBroadcaster; -import javax.ws.rs.sse.SseEventSink; - -@ApplicationScoped -@Path("stock") -public class SseResource { - - @Inject - private StockService stockService; - - private Sse sse; - private SseBroadcaster sseBroadcaster; - private OutboundSseEvent.Builder eventBuilder; - - @Context - public void setSse(Sse sse) { - this.sse = sse; - this.eventBuilder = sse.newEventBuilder(); - this.sseBroadcaster = sse.newBroadcaster(); - } - - @GET - @Path("prices") - @Produces("text/event-stream") - public void getStockPrices(@Context SseEventSink sseEventSink, - @HeaderParam(HttpHeaders.LAST_EVENT_ID_HEADER) @DefaultValue("-1") int lastReceivedId) { - - int lastEventId = 1; - if (lastReceivedId != -1) { - lastEventId = ++lastReceivedId; - } - boolean running = true; - while (running) { - Stock stock = stockService.getNextTransaction(lastEventId); - if (stock != null) { - OutboundSseEvent sseEvent = this.eventBuilder - .name("stock") - .id(String.valueOf(lastEventId)) - .mediaType(MediaType.APPLICATION_JSON_TYPE) - .data(Stock.class, stock) - .reconnectDelay(3000) - .comment("price change") - .build(); - sseEventSink.send(sseEvent); - lastEventId++; - } - //Simulate connection close - if (lastEventId % 5 == 0) { - sseEventSink.close(); - break; - } - - try { - //Wait 5 seconds - Thread.sleep(5 * 1000); - } catch (InterruptedException ex) { - // ... - } - //Simulatae a while boucle break - running = lastEventId <= 2000; - } - sseEventSink.close(); - } - - @GET - @Path("subscribe") - @Produces(MediaType.SERVER_SENT_EVENTS) - public void listen(@Context SseEventSink sseEventSink) { - sseEventSink.send(sse.newEvent("Welcome !")); - this.sseBroadcaster.register(sseEventSink); - sseEventSink.send(sse.newEvent("You are registred !")); - } - - @GET - @Path("publish") - public void broadcast() { - Runnable r = new Runnable() { - @Override - public void run() { - int lastEventId = 0; - boolean running = true; - while (running) { - lastEventId++; - Stock stock = stockService.getNextTransaction(lastEventId); - if (stock != null) { - OutboundSseEvent sseEvent = eventBuilder - .name("stock") - .id(String.valueOf(lastEventId)) - .mediaType(MediaType.APPLICATION_JSON_TYPE) - .data(Stock.class, stock) - .reconnectDelay(3000) - .comment("price change") - .build(); - sseBroadcaster.broadcast(sseEvent); - } - try { - //Wait 5 seconds - Thread.currentThread().sleep(5 * 1000); - } catch (InterruptedException ex) { - // ... - } - //Simulatae a while boucle break - running = lastEventId <= 2000; - } - } - }; - new Thread(r).start(); - } -} diff --git a/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/Stock.java b/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/Stock.java deleted file mode 100644 index a186b32771..0000000000 --- a/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/Stock.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.baeldung.sse.jaxrs; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -public class Stock { - private Integer id; - private String name; - private BigDecimal price; - LocalDateTime dateTime; - - public Stock(Integer id, String name, BigDecimal price, LocalDateTime dateTime) { - this.id = id; - this.name = name; - this.price = price; - this.dateTime = dateTime; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public BigDecimal getPrice() { - return price; - } - - public void setPrice(BigDecimal price) { - this.price = price; - } - - public LocalDateTime getDateTime() { - return dateTime; - } - - public void setDateTime(LocalDateTime dateTime) { - this.dateTime = dateTime; - } -} diff --git a/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/StockService.java b/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/StockService.java deleted file mode 100644 index 15818ead5d..0000000000 --- a/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/StockService.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.baeldung.sse.jaxrs; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.context.Initialized; -import javax.enterprise.event.Event; -import javax.enterprise.event.Observes; -import javax.inject.Inject; -import javax.inject.Named; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Random; -import java.util.concurrent.atomic.AtomicInteger; - -@ApplicationScoped -@Named -public class StockService { - - private static final BigDecimal UP = BigDecimal.valueOf(1.05f); - private static final BigDecimal DOWN = BigDecimal.valueOf(0.95f); - - List stockNames = Arrays.asList("GOOG", "IBM", "MS", "GOOG", "YAHO"); - List stocksDB = new ArrayList<>(); - private AtomicInteger counter = new AtomicInteger(0); - - public void init(@Observes @Initialized(ApplicationScoped.class) Object init) { - //Open price - System.out.println("@Start Init ..."); - stockNames.forEach(stockName -> { - stocksDB.add(new Stock(counter.incrementAndGet(), stockName, generateOpenPrice(), LocalDateTime.now())); - }); - - Runnable runnable = new Runnable() { - @Override - public void run() { - //Simulate Change price and put every x seconds - while (true) { - int indx = new Random().nextInt(stockNames.size()); - String stockName = stockNames.get(indx); - BigDecimal price = getLastPrice(stockName); - BigDecimal newprice = changePrice(price); - Stock stock = new Stock(counter.incrementAndGet(), stockName, newprice, LocalDateTime.now()); - stocksDB.add(stock); - - int r = new Random().nextInt(30); - try { - Thread.currentThread().sleep(r*1000); - } catch (InterruptedException ex) { - // ... - } - } - } - }; - new Thread(runnable).start(); - System.out.println("@End Init ..."); - } - - public Stock getNextTransaction(Integer lastEventId) { - return stocksDB.stream().filter(s -> s.getId().equals(lastEventId)).findFirst().orElse(null); - } - - BigDecimal generateOpenPrice() { - float min = 70; - float max = 120; - return BigDecimal.valueOf(min + new Random().nextFloat() * (max - min)).setScale(4,RoundingMode.CEILING); - } - - BigDecimal changePrice(BigDecimal price) { - return Math.random() >= 0.5 ? price.multiply(UP).setScale(4,RoundingMode.CEILING) : price.multiply(DOWN).setScale(4,RoundingMode.CEILING); - } - - private BigDecimal getLastPrice(String stockName) { - return stocksDB.stream().filter(stock -> stock.getName().equals(stockName)).findFirst().get().getPrice(); - } -} diff --git a/sse-jaxrs/sse-jaxrs-server/src/main/liberty/config/server.xml b/sse-jaxrs/sse-jaxrs-server/src/main/liberty/config/server.xml deleted file mode 100644 index 9bf66d7795..0000000000 --- a/sse-jaxrs/sse-jaxrs-server/src/main/liberty/config/server.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - jaxrs-2.1 - cdi-2.0 - - - diff --git a/sse-jaxrs/sse-jaxrs-server/src/main/resources/META-INF/beans.xml b/sse-jaxrs/sse-jaxrs-server/src/main/resources/META-INF/beans.xml deleted file mode 100644 index 4f0b3cdeeb..0000000000 --- a/sse-jaxrs/sse-jaxrs-server/src/main/resources/META-INF/beans.xml +++ /dev/null @@ -1,6 +0,0 @@ - - \ No newline at end of file diff --git a/sse-jaxrs/sse-jaxrs-server/src/main/resources/logback.xml b/sse-jaxrs/sse-jaxrs-server/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/sse-jaxrs/sse-jaxrs-server/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/sse-jaxrs/sse-jaxrs-server/src/main/webapp/WEB-INF/web.xml b/sse-jaxrs/sse-jaxrs-server/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index b4b8121fdd..0000000000 --- a/sse-jaxrs/sse-jaxrs-server/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - Hello Servlet - - - index.html - - - diff --git a/sse-jaxrs/sse-jaxrs-server/src/main/webapp/index.html b/sse-jaxrs/sse-jaxrs-server/src/main/webapp/index.html deleted file mode 100644 index 9015a7a32c..0000000000 --- a/sse-jaxrs/sse-jaxrs-server/src/main/webapp/index.html +++ /dev/null @@ -1 +0,0 @@ -index diff --git a/sse-jaxrs/sse-jaxrs-server/src/main/webapp/sse-broadcast.html b/sse-jaxrs/sse-jaxrs-server/src/main/webapp/sse-broadcast.html deleted file mode 100644 index 5a46e2a5d3..0000000000 --- a/sse-jaxrs/sse-jaxrs-server/src/main/webapp/sse-broadcast.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - Server-Sent Event Broadcasting - - -

Stock prices :

-
-
    -
-
- - - \ No newline at end of file diff --git a/sse-jaxrs/sse-jaxrs-server/src/main/webapp/sse.html b/sse-jaxrs/sse-jaxrs-server/src/main/webapp/sse.html deleted file mode 100644 index 8fddae4717..0000000000 --- a/sse-jaxrs/sse-jaxrs-server/src/main/webapp/sse.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - Server-Sent Event - - -

Stock prices :

-
-
    -
-
- - - \ No newline at end of file