├── ConfigurationService ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── config_file │ ├── config-server-client-development.properties │ ├── config-server-client-production.properties │ └── config-server-client.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── app │ │ │ └── services │ │ │ └── ConfigurationServiceApplication.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── app │ └── services │ └── ConfigurationServiceApplicationTests.java ├── EmployeeAccessService ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── Dockerfile ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── client │ │ │ └── app │ │ │ └── service │ │ │ ├── EmployeeAccessServiceApplication.java │ │ │ ├── bean │ │ │ └── EmployeeBean.java │ │ │ ├── config │ │ │ └── SwaggerConfig.java │ │ │ ├── controller │ │ │ ├── EmployeeClientController.java │ │ │ └── MessageFromConfig.java │ │ │ └── repository │ │ │ ├── EmployeeRepositoryAccess.java │ │ │ └── EmployeeRepositoryAccessImpl.java │ ├── resources │ │ ├── application.yml │ │ └── bootstrap.yml │ └── webapp │ │ └── WEB-INF │ │ └── jsp │ │ ├── index.jsp │ │ ├── serviceError.jsp │ │ ├── userDetails.jsp │ │ └── userProfiles.jsp │ └── test │ └── java │ └── com │ └── client │ └── app │ └── service │ └── EmployeeAccessServiceApplicationTests.java ├── EmployeeFeignClientService ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── am │ │ │ └── app │ │ │ └── emp │ │ │ └── client │ │ │ ├── EmployeeFeignClientService.java │ │ │ ├── bean │ │ │ ├── AlbumBean.java │ │ │ └── EmployeeBean.java │ │ │ ├── controller │ │ │ └── EmployeeClientController.java │ │ │ └── service │ │ │ ├── AlbumClientService.java │ │ │ ├── EmployeeDataService.java │ │ │ └── fallback │ │ │ └── EmployeeDataServiceFallback.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── am │ └── app │ └── EmployeeFeignClientServiceTests.java ├── EmployeeProducerService ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── Dockerfile ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── app │ │ │ └── emp │ │ │ └── producer │ │ │ ├── EmployeeProducerServiceApplication.java │ │ │ ├── bean │ │ │ └── EmployeeBean.java │ │ │ ├── controller │ │ │ └── EmployeeController.java │ │ │ └── dao │ │ │ ├── EmployeeRepository.java │ │ │ └── EmployeeRepositoryImpl.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── app │ └── service │ └── EmployeeProducerServiceApplicationTests.java ├── EurekaServerProj ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── Dockerfile ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── app │ │ │ └── service │ │ │ └── EurekaServerProjApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── app │ └── service │ └── EurekaServerProjApplicationTests.java ├── GatewayServerZuul ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── app │ │ │ └── services │ │ │ ├── GatewayServerZuulApplication.java │ │ │ ├── filters │ │ │ ├── ErrorFilter.java │ │ │ ├── PostFilter.java │ │ │ ├── PreFilter.java │ │ │ └── RouteFilter.java │ │ │ ├── model │ │ │ ├── Authority.java │ │ │ ├── AuthorityName.java │ │ │ └── User.java │ │ │ └── security │ │ │ ├── JwtAuthenticationEntryPoint.java │ │ │ ├── JwtAuthenticationRequest.java │ │ │ ├── JwtAuthorizationTokenFilter.java │ │ │ ├── JwtTokenUtil.java │ │ │ ├── JwtUser.java │ │ │ ├── JwtUserFactory.java │ │ │ ├── config │ │ │ └── WebSecurityConfig.java │ │ │ ├── controller │ │ │ ├── AuthenticationException.java │ │ │ ├── AuthenticationRestController.java │ │ │ ├── MethodProtectedRestController.java │ │ │ └── UserRestController.java │ │ │ ├── repository │ │ │ └── UserRepository.java │ │ │ └── service │ │ │ ├── JwtAuthenticationResponse.java │ │ │ └── JwtUserDetailsService.java │ └── resources │ │ ├── bootstrap.yml │ │ └── data.sql │ └── test │ └── java │ └── com │ └── app │ └── services │ └── GatewayServerZuulApplicationTests.java ├── HystrixDashboard ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── app │ │ │ └── services │ │ │ └── HystrixDashboardApplication.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── app │ └── services │ └── HystrixDashboardApplicationTests.java ├── README.md ├── TicketSystemService ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── Dockerfile ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── app │ │ │ └── service │ │ │ ├── TicketSystemServiceApplication.java │ │ │ ├── bean │ │ │ └── TicketSystemBean.java │ │ │ ├── controller │ │ │ └── TicketSystemController.java │ │ │ └── dao │ │ │ └── TicketSystemDoa.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── app │ └── service │ └── TicketSystemServiceApplicationTests.java ├── employee-microservice-client-development.properties ├── employee-microservice-client-production.properties └── employee-microservice-client.properties /ConfigurationService/.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/ -------------------------------------------------------------------------------- /ConfigurationService/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamtech/SpringBoot-Microservice-Eurka-Zuul/b232aed6c5ddd16913a934a80845c95d9d18067d/ConfigurationService/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /ConfigurationService/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /ConfigurationService/config_file/config-server-client-development.properties: -------------------------------------------------------------------------------- 1 | msg = Hello - this is from config server – Development environment 2 | -------------------------------------------------------------------------------- /ConfigurationService/config_file/config-server-client-production.properties: -------------------------------------------------------------------------------- 1 | msg = Hello world - this is from config server – Production environment 2 | -------------------------------------------------------------------------------- /ConfigurationService/config_file/config-server-client.properties: -------------------------------------------------------------------------------- 1 | msg = Hello - this is from config server 2 | -------------------------------------------------------------------------------- /ConfigurationService/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Migwn, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | echo $MAVEN_PROJECTBASEDIR 205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 206 | 207 | # For Cygwin, switch paths to Windows format before running java 208 | if $cygwin; then 209 | [ -n "$M2_HOME" ] && 210 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 211 | [ -n "$JAVA_HOME" ] && 212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 213 | [ -n "$CLASSPATH" ] && 214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 215 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 217 | fi 218 | 219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 220 | 221 | exec "$JAVACMD" \ 222 | $MAVEN_OPTS \ 223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 226 | -------------------------------------------------------------------------------- /ConfigurationService/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 | -------------------------------------------------------------------------------- /ConfigurationService/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | ConfigurationService 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | ConfigurationService 12 | Configuration Service For Employee Services 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.3.10.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | Hoxton.SR11 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-actuator 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-data-rest 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-web 40 | 41 | 42 | org.springframework.cloud 43 | spring-cloud-config-server 44 | 45 | 46 | org.springframework.cloud 47 | spring-cloud-starter-config 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-test 53 | test 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-starter-netflix-eureka-client 58 | 59 | 60 | org.springframework.cloud 61 | spring-cloud-starter-netflix-eureka-server 62 | 63 | 64 | 65 | 66 | 67 | 68 | org.springframework.cloud 69 | spring-cloud-dependencies 70 | ${spring-cloud.version} 71 | pom 72 | import 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | org.springframework.boot 81 | spring-boot-maven-plugin 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ConfigurationService/src/main/java/com/app/services/ConfigurationServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.app.services; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.config.server.EnableConfigServer; 6 | 7 | @EnableConfigServer 8 | @SpringBootApplication 9 | public class ConfigurationServiceApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConfigurationServiceApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ConfigurationService/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: config-server-client 4 | profiles: 5 | active: development 6 | cloud: 7 | config: 8 | server: 9 | git: 10 | uri: file:///E:/workspace/config_file # https://github.com/iamtech/ConfigurationService/tree/master/config_file # file:///E/workspace/ConfigurationService/config_file 11 | 12 | 13 | eureka: 14 | client: 15 | serviceUrl: 16 | defaultZone: http://localhost:8761/eureka/ 17 | 18 | server: 19 | port: 8094 20 | 21 | 22 | -------------------------------------------------------------------------------- /ConfigurationService/src/test/java/com/app/services/ConfigurationServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.app.services; 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 ConfigurationServiceApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /EmployeeAccessService/.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/ -------------------------------------------------------------------------------- /EmployeeAccessService/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamtech/SpringBoot-Microservice-Eurka-Zuul/b232aed6c5ddd16913a934a80845c95d9d18067d/EmployeeAccessService/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /EmployeeAccessService/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /EmployeeAccessService/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | VOLUME /tmp 3 | ADD target/EmployeeAccessService-0.0.1-SNAPSHOT.jar EmployeeAccessService.jar 4 | RUN bash -c 'touch /EmployeeAccessService.jar' 5 | ENV JAVA_OPTS="" 6 | ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /EmployeeAccessService.jar"] -------------------------------------------------------------------------------- /EmployeeAccessService/README.md: -------------------------------------------------------------------------------- 1 | # Employee Access Service : Gets data from Employee Producer Service 2 | 3 | # To Refresh Config Data at runtime: 4 | 5 | Following Tag added to bootstrap.yml to refresh the Config Server Properties 6 | 7 | management: 8 | endpoints: 9 | web: 10 | exposure: 11 | include: refresh 12 | 13 | 14 | Use postman and make a post request to: 15 | 16 | http://localhost:8099/actuator/refresh 17 | -------------------------------------------------------------------------------- /EmployeeAccessService/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Migwn, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | echo $MAVEN_PROJECTBASEDIR 205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 206 | 207 | # For Cygwin, switch paths to Windows format before running java 208 | if $cygwin; then 209 | [ -n "$M2_HOME" ] && 210 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 211 | [ -n "$JAVA_HOME" ] && 212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 213 | [ -n "$CLASSPATH" ] && 214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 215 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 217 | fi 218 | 219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 220 | 221 | exec "$JAVACMD" \ 222 | $MAVEN_OPTS \ 223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 226 | -------------------------------------------------------------------------------- /EmployeeAccessService/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 | -------------------------------------------------------------------------------- /EmployeeAccessService/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | EmployeeAccessService 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | EmployeeAccessService 12 | Employee Catalog Microservice 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.3.10.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | Hoxton.SR11 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-actuator 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-data-rest 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-web 40 | 41 | 42 | org.springframework.cloud 43 | spring-cloud-starter-netflix-eureka-client 44 | 45 | 46 | org.springframework.cloud 47 | spring-cloud-starter-netflix-eureka-server 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-test 53 | 54 | 55 | 56 | 57 | 58 | org.springframework.cloud 59 | spring-cloud-starter-config 60 | 61 | 62 | 63 | 64 | org.springframework.cloud 65 | spring-cloud-starter-netflix-hystrix 66 | 67 | 68 | 69 | 70 | org.apache.tomcat.embed 71 | tomcat-embed-jasper 72 | provided 73 | 74 | 75 | javax.servlet 76 | jstl 77 | 78 | 79 | 80 | io.springfox 81 | springfox-swagger2 82 | 2.9.2 83 | 84 | 85 | io.springfox 86 | springfox-swagger-ui 87 | 2.6.1 88 | compile 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | org.springframework.cloud 98 | spring-cloud-dependencies 99 | ${spring-cloud.version} 100 | pom 101 | import 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | org.springframework.boot 110 | spring-boot-maven-plugin 111 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /EmployeeAccessService/src/main/java/com/client/app/service/EmployeeAccessServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.client.app.service; 2 | 3 | import java.io.IOException; 4 | 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; 8 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 9 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.ComponentScan; 12 | import org.springframework.web.client.RestTemplate; 13 | import org.xmlpull.v1.XmlPullParserException; 14 | 15 | import com.client.app.service.controller.EmployeeClientController; 16 | import com.client.app.service.controller.MessageFromConfig; 17 | import com.client.app.service.repository.EmployeeRepositoryAccess; 18 | import com.client.app.service.repository.EmployeeRepositoryAccessImpl; 19 | 20 | import springfox.documentation.builders.PathSelectors; 21 | import springfox.documentation.builders.RequestHandlerSelectors; 22 | import springfox.documentation.service.Tag; 23 | import springfox.documentation.spi.DocumentationType; 24 | import springfox.documentation.spring.web.plugins.Docket; 25 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 26 | 27 | @EnableSwagger2 28 | @EnableCircuitBreaker 29 | @EnableDiscoveryClient 30 | @SpringBootApplication(scanBasePackages={"client.app.service"}) 31 | @ComponentScan(basePackageClasses = {EmployeeClientController.class,MessageFromConfig.class}, basePackages="client.app.service") 32 | public class EmployeeAccessServiceApplication { 33 | 34 | public static final String EMPLOYEE_DATA_SERVICE_URL = "http://employee-microservice-dataset"; 35 | 36 | public static void main(String[] args) { 37 | SpringApplication.run(EmployeeAccessServiceApplication.class, args); 38 | } 39 | 40 | @Bean 41 | @LoadBalanced 42 | public RestTemplate restTemplate() { 43 | return new RestTemplate(); 44 | } 45 | 46 | @Bean 47 | public EmployeeRepositoryAccess profileRepository(){ 48 | return new EmployeeRepositoryAccessImpl(EMPLOYEE_DATA_SERVICE_URL); 49 | } 50 | 51 | @Bean 52 | public Docket api() throws IOException, XmlPullParserException { 53 | return new Docket(DocumentationType.SWAGGER_2) 54 | .select() 55 | .apis(RequestHandlerSelectors.basePackage("com.client.app.service.controller")) 56 | .paths(PathSelectors.any()) 57 | .build() 58 | .tags(new Tag("EmployeeClient","Controller for getting Employee data from Producer Service "), 59 | new Tag("MsgConfigServer", "Get Message From Config Server")); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /EmployeeAccessService/src/main/java/com/client/app/service/bean/EmployeeBean.java: -------------------------------------------------------------------------------- 1 | package com.client.app.service.bean; 2 | 3 | import java.io.Serializable; 4 | 5 | public class EmployeeBean implements Serializable{ 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private String userId; 10 | private String name; 11 | 12 | public String getUserId() { 13 | return userId; 14 | } 15 | public void setUserId(String userId) { 16 | this.userId = userId; 17 | } 18 | public String getName() { 19 | return name; 20 | } 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "Employee [userId=" + userId + ", name=" + name + "]"; 28 | } 29 | 30 | public EmployeeBean() { 31 | // TODO Auto-generated constructor stub 32 | } 33 | 34 | public EmployeeBean(String userId, String name) { 35 | super(); 36 | this.userId = userId; 37 | this.name = name; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /EmployeeAccessService/src/main/java/com/client/app/service/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.client.app.service.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | 5 | 6 | @Configuration 7 | public class SwaggerConfig { 8 | 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /EmployeeAccessService/src/main/java/com/client/app/service/controller/EmployeeClientController.java: -------------------------------------------------------------------------------- 1 | package com.client.app.service.controller; 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.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | 9 | import com.client.app.service.repository.EmployeeRepositoryAccess; 10 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; 11 | 12 | import io.swagger.annotations.Api; 13 | 14 | @Controller 15 | @Api(tags={"EmployeeClient"}) 16 | public class EmployeeClientController { 17 | 18 | @Autowired 19 | EmployeeRepositoryAccess empRepository; 20 | 21 | @RequestMapping("/") 22 | public String home(){ 23 | return "index"; 24 | } 25 | 26 | @RequestMapping("/userProfiles") 27 | public String profileList(Model model) { 28 | model.addAttribute("profiles", empRepository.getAllProfiles()); 29 | return "userProfiles"; 30 | } 31 | 32 | @HystrixCommand(fallbackMethod = "profileNotFound") 33 | @RequestMapping("/userDetails") 34 | public String profileDetails(@RequestParam("id") String userId, Model model) { 35 | model.addAttribute("profile", empRepository.getProfile(userId)); 36 | return "userDetails"; 37 | } 38 | 39 | public String profileNotFound(String userId, Model mode) { 40 | return "serviceError"; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /EmployeeAccessService/src/main/java/com/client/app/service/controller/MessageFromConfig.java: -------------------------------------------------------------------------------- 1 | package com.client.app.service.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.cloud.context.config.annotation.RefreshScope; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import io.swagger.annotations.Api; 9 | 10 | @RefreshScope 11 | @RestController 12 | @Api(tags={"MsgConfigServer"}) 13 | public class MessageFromConfig { 14 | 15 | @Value("${msg:Hello - Config Server is not working..pelase check}") 16 | private String message; 17 | 18 | @RequestMapping("/message") 19 | String getMessage() { 20 | return this.message; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /EmployeeAccessService/src/main/java/com/client/app/service/repository/EmployeeRepositoryAccess.java: -------------------------------------------------------------------------------- 1 | package com.client.app.service.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.client.app.service.bean.EmployeeBean; 6 | 7 | public interface EmployeeRepositoryAccess { 8 | 9 | List getAllProfiles(); 10 | EmployeeBean getProfile(String userId); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /EmployeeAccessService/src/main/java/com/client/app/service/repository/EmployeeRepositoryAccessImpl.java: -------------------------------------------------------------------------------- 1 | package com.client.app.service.repository; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Repository; 8 | import org.springframework.web.client.RestTemplate; 9 | 10 | import com.client.app.service.bean.EmployeeBean; 11 | 12 | public class EmployeeRepositoryAccessImpl implements EmployeeRepositoryAccess{ 13 | 14 | @Autowired 15 | protected RestTemplate restTemplate; 16 | 17 | protected String serviceUrl; 18 | 19 | public EmployeeRepositoryAccessImpl(String serviceUrl) { 20 | this.serviceUrl = serviceUrl.startsWith("http") ? serviceUrl 21 | : "http://" + serviceUrl; 22 | } 23 | 24 | @Override 25 | public List getAllProfiles() { 26 | EmployeeBean[] profiles = restTemplate.getForObject(serviceUrl+"/profiles", EmployeeBean[].class); 27 | return Arrays.asList(profiles); 28 | } 29 | 30 | @Override 31 | public EmployeeBean getProfile(String userId) { 32 | return restTemplate.getForObject(serviceUrl + "/profiles/{id}", 33 | EmployeeBean.class, userId); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /EmployeeAccessService/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: employee-microservice-client 4 | mvc: 5 | view: 6 | prefix: /WEB-INF/jsp/ 7 | suffix: .jsp 8 | 9 | 10 | server: 11 | port: 8099 12 | 13 | # Discovery Server Access 14 | eureka: 15 | client: 16 | serviceUrl: 17 | defaultZone: http://localhost:8761/eureka/ 18 | 19 | # Disable Spring Boot's "Whitelabel" default error page, so we can use our own 20 | error: 21 | whitelabel: 22 | enabled: false 23 | 24 | -------------------------------------------------------------------------------- /EmployeeAccessService/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: development 4 | cloud: 5 | config: 6 | uri: http://localhost:8094 7 | 8 | management: 9 | endpoints: 10 | web: 11 | exposure: 12 | include: refresh,health,info,hystrix.stream -------------------------------------------------------------------------------- /EmployeeAccessService/src/main/webapp/WEB-INF/jsp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | First Page - Microservices 5 | 6 | 7 | 8 |

Index Page

9 |
10 |
11 |

Employee List

12 |

View Employee List

13 |
14 |
15 | -------------------------------------------------------------------------------- /EmployeeAccessService/src/main/webapp/WEB-INF/jsp/serviceError.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Bad Request 5 | 6 | 7 | 8 |

Hystrix Fallback Page

9 |

Service Unavailable

10 | 11 | -------------------------------------------------------------------------------- /EmployeeAccessService/src/main/webapp/WEB-INF/jsp/userDetails.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | 3 | 4 | 5 | All Employee Page 6 | 7 | 8 | 9 |
10 |
11 |

Employee Details

12 |
    13 |
  • Employee ID: ${profile.userId}
  • 14 |
  • Employee Name: ${profile.name}
  • 15 |
16 |
17 |
18 | 19 | -------------------------------------------------------------------------------- /EmployeeAccessService/src/main/webapp/WEB-INF/jsp/userProfiles.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | 3 | 4 | 5 | Employees Name 6 | 7 | 8 | 9 |
10 |
11 |

Employee List

12 | 17 |
18 |
19 | 20 | -------------------------------------------------------------------------------- /EmployeeAccessService/src/test/java/com/client/app/service/EmployeeAccessServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.client.app.service; 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 EmployeeAccessServiceApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /EmployeeFeignClientService/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 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 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /EmployeeFeignClientService/.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 | -------------------------------------------------------------------------------- /EmployeeFeignClientService/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamtech/SpringBoot-Microservice-Eurka-Zuul/b232aed6c5ddd16913a934a80845c95d9d18067d/EmployeeFeignClientService/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /EmployeeFeignClientService/.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 | -------------------------------------------------------------------------------- /EmployeeFeignClientService/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 | -------------------------------------------------------------------------------- /EmployeeFeignClientService/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.10.RELEASE 9 | 10 | 11 | com.am.app 12 | EmployeClient 13 | 0.0.1-SNAPSHOT 14 | EmployeeFeignClientService 15 | Employee Client Rest API using OpenFeign 16 | 17 | 18 | 1.8 19 | Hoxton.SR11 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-openfeign 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-starter-netflix-eureka-client 34 | 35 | 36 | 37 | org.springframework.cloud 38 | spring-cloud-starter-netflix-hystrix 39 | 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-actuator 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-devtools 50 | runtime 51 | true 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-starter-test 56 | 57 | 58 | 59 | org.junit.vintage 60 | junit-vintage-engine 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | org.springframework.cloud 70 | spring-cloud-dependencies 71 | ${spring-cloud.version} 72 | pom 73 | import 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | org.springframework.boot 82 | spring-boot-maven-plugin 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /EmployeeFeignClientService/src/main/java/com/am/app/emp/client/EmployeeFeignClientService.java: -------------------------------------------------------------------------------- 1 | package com.am.app.emp.client; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.openfeign.EnableFeignClients; 8 | 9 | @SpringBootApplication 10 | @EnableDiscoveryClient 11 | @EnableFeignClients 12 | @EnableCircuitBreaker 13 | public class EmployeeFeignClientService { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(EmployeeFeignClientService.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /EmployeeFeignClientService/src/main/java/com/am/app/emp/client/bean/AlbumBean.java: -------------------------------------------------------------------------------- 1 | package com.am.app.emp.client.bean; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 6 | import com.fasterxml.jackson.annotation.JsonAnySetter; 7 | import com.fasterxml.jackson.annotation.JsonIgnore; 8 | import com.fasterxml.jackson.annotation.JsonInclude; 9 | import com.fasterxml.jackson.annotation.JsonProperty; 10 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 11 | 12 | @JsonInclude(JsonInclude.Include.NON_NULL) 13 | @JsonPropertyOrder({ 14 | "userId", 15 | "id", 16 | "title" 17 | }) 18 | public class AlbumBean { 19 | 20 | @JsonProperty("userId") 21 | private Integer userId; 22 | @JsonProperty("id") 23 | private Integer id; 24 | @JsonProperty("title") 25 | private String title; 26 | @JsonIgnore 27 | private Map additionalProperties = new HashMap(); 28 | 29 | @JsonProperty("userId") 30 | public Integer getUserId() { 31 | return userId; 32 | } 33 | 34 | @JsonProperty("userId") 35 | public void setUserId(Integer userId) { 36 | this.userId = userId; 37 | } 38 | 39 | @JsonProperty("id") 40 | public Integer getId() { 41 | return id; 42 | } 43 | 44 | @JsonProperty("id") 45 | public void setId(Integer id) { 46 | this.id = id; 47 | } 48 | 49 | @JsonProperty("title") 50 | public String getTitle() { 51 | return title; 52 | } 53 | 54 | @JsonProperty("title") 55 | public void setTitle(String title) { 56 | this.title = title; 57 | } 58 | 59 | @JsonAnyGetter 60 | public Map getAdditionalProperties() { 61 | return this.additionalProperties; 62 | } 63 | 64 | @JsonAnySetter 65 | public void setAdditionalProperty(String name, Object value) { 66 | this.additionalProperties.put(name, value); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /EmployeeFeignClientService/src/main/java/com/am/app/emp/client/bean/EmployeeBean.java: -------------------------------------------------------------------------------- 1 | package com.am.app.emp.client.bean; 2 | 3 | import java.io.Serializable; 4 | 5 | public class EmployeeBean implements Serializable{ 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private String userId; 10 | private String name; 11 | 12 | public String getUserId() { 13 | return userId; 14 | } 15 | public void setUserId(String userId) { 16 | this.userId = userId; 17 | } 18 | public String getName() { 19 | return name; 20 | } 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "Employee [userId=" + userId + ", name=" + name + "]"; 28 | } 29 | 30 | public EmployeeBean() { 31 | // TODO Auto-generated constructor stub 32 | } 33 | 34 | public EmployeeBean(String userId, String name) { 35 | super(); 36 | this.userId = userId; 37 | this.name = name; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /EmployeeFeignClientService/src/main/java/com/am/app/emp/client/controller/EmployeeClientController.java: -------------------------------------------------------------------------------- 1 | package com.am.app.emp.client.controller; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import com.am.app.emp.client.bean.AlbumBean; 10 | import com.am.app.emp.client.bean.EmployeeBean; 11 | import com.am.app.emp.client.service.AlbumClientService; 12 | import com.am.app.emp.client.service.EmployeeDataService; 13 | 14 | @RestController 15 | public class EmployeeClientController { 16 | 17 | @Autowired 18 | AlbumClientService albumClientService; 19 | 20 | @Autowired 21 | EmployeeDataService employeeDataService; 22 | 23 | //calling Rest API from other service registered under same Eureka server 24 | @GetMapping("/employees") 25 | public List getAllEmployees(){ 26 | List employeeList = employeeDataService.getAllProfiles(); 27 | employeeList.stream().forEach(e -> System.out.println(e.getUserId()+" "+e.getName())); 28 | return employeeList; 29 | } 30 | 31 | // calling external API for testing 32 | @GetMapping("/albums") 33 | public List showAllAlbums(){ 34 | List albumList = albumClientService.getAllAlbums(); 35 | albumList.stream().forEach(a -> System.out.println(a.getId()+" "+a.getUserId()+" "+a.getTitle())); 36 | return albumList; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /EmployeeFeignClientService/src/main/java/com/am/app/emp/client/service/AlbumClientService.java: -------------------------------------------------------------------------------- 1 | package com.am.app.emp.client.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | 8 | import com.am.app.emp.client.bean.AlbumBean; 9 | 10 | // For testing External Rest APi using OpenFeign 11 | @FeignClient(url="https://jsonplaceholder.typicode.com", name="album-service") 12 | public interface AlbumClientService { 13 | 14 | @GetMapping("/albums") 15 | public List getAllAlbums(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /EmployeeFeignClientService/src/main/java/com/am/app/emp/client/service/EmployeeDataService.java: -------------------------------------------------------------------------------- 1 | package com.am.app.emp.client.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | 8 | import com.am.app.emp.client.bean.EmployeeBean; 9 | import com.am.app.emp.client.service.fallback.EmployeeDataServiceFallback; 10 | 11 | //Calling Rest API from other service registered under same Eureka server 12 | //Feign contacts the Eureka server for employee-microservice-dataset Service name to fetch data 13 | //Feign will look for Fallback method in EmployeeDataServiceFallback.class 14 | @FeignClient(name="employee-microservice-dataset", fallback = EmployeeDataServiceFallback.class) 15 | public interface EmployeeDataService { 16 | 17 | @GetMapping("/profiles") 18 | // @HystrixCommand(fallbackMethod = "getDefaultAlbums") 19 | public List getAllProfiles(); 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /EmployeeFeignClientService/src/main/java/com/am/app/emp/client/service/fallback/EmployeeDataServiceFallback.java: -------------------------------------------------------------------------------- 1 | package com.am.app.emp.client.service.fallback; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.am.app.emp.client.bean.EmployeeBean; 9 | import com.am.app.emp.client.service.EmployeeDataService; 10 | 11 | @Component 12 | public class EmployeeDataServiceFallback implements EmployeeDataService{ 13 | 14 | 15 | // Fallback method 16 | @Override 17 | public List getAllProfiles(){ 18 | 19 | List dList = new ArrayList(); 20 | dList.add(new EmployeeBean("0000", "Default_Employee_Hystrix")); 21 | return dList; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /EmployeeFeignClientService/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: employee-service-feign-client 4 | 5 | server: 6 | port: 8005 7 | 8 | 9 | # Discovery Server Access 10 | eureka: 11 | client: 12 | serviceUrl: 13 | defaultZone: http://localhost:8761/eureka/ 14 | 15 | 16 | # Must have Hystrix on the classpath and also set feign.hystrix.enabled=true to have Feign automatically wrap methods in Hystrix commands. 17 | feign: 18 | hystrix: 19 | enabled: true 20 | 21 | # To exposes the /actuator/hystrix.stream as a management endpoint for Hystrix Service for monitoring 22 | management: 23 | endpoints: 24 | web: 25 | exposure: 26 | include: hystrix.stream -------------------------------------------------------------------------------- /EmployeeFeignClientService/src/test/java/com/am/app/EmployeeFeignClientServiceTests.java: -------------------------------------------------------------------------------- 1 | package com.am.app; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class EmployeeFeignClientServiceTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /EmployeeProducerService/.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/ -------------------------------------------------------------------------------- /EmployeeProducerService/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamtech/SpringBoot-Microservice-Eurka-Zuul/b232aed6c5ddd16913a934a80845c95d9d18067d/EmployeeProducerService/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /EmployeeProducerService/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /EmployeeProducerService/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | VOLUME /tmp 3 | ADD target/EmployeeProducerService-0.0.1-SNAPSHOT.jar EmployeeProducerService.jar 4 | RUN bash -c 'touch /EmployeeProducerService.jar' 5 | ENV JAVA_OPTS="" 6 | ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /EmployeeProducerService.jar"] -------------------------------------------------------------------------------- /EmployeeProducerService/README.md: -------------------------------------------------------------------------------- 1 | # Employee Producer Service : Creates data for Employee Client Service 2 | -------------------------------------------------------------------------------- /EmployeeProducerService/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 | -------------------------------------------------------------------------------- /EmployeeProducerService/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | EmployeeProducerService 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | EmployeeProducerService 12 | Employee Catalog Microservice 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.3.10.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | Hoxton.SR11 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-web 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-actuator 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-data-rest 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-starter-netflix-eureka-client 45 | 46 | 47 | org.springframework.cloud 48 | spring-cloud-starter-netflix-eureka-server 49 | 50 | 51 | 52 | org.hsqldb 53 | hsqldb 54 | runtime 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-starter-test 59 | 60 | 61 | 62 | 63 | 64 | org.springframework.cloud 65 | spring-cloud-starter-netflix-hystrix 66 | 67 | 68 | 69 | 70 | 71 | 72 | org.springframework.cloud 73 | spring-cloud-dependencies 74 | ${spring-cloud.version} 75 | pom 76 | import 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | org.springframework.boot 85 | spring-boot-maven-plugin 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /EmployeeProducerService/src/main/java/com/app/emp/producer/EmployeeProducerServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.app.emp.producer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.context.annotation.ComponentScan; 8 | 9 | import com.app.emp.producer.controller.EmployeeController; 10 | 11 | @EnableCircuitBreaker 12 | @SpringBootApplication 13 | @EnableDiscoveryClient 14 | @ComponentScan(basePackageClasses = EmployeeController.class,basePackages="com.app.emp.producer") 15 | 16 | public class EmployeeProducerServiceApplication { 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(EmployeeProducerServiceApplication.class, args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /EmployeeProducerService/src/main/java/com/app/emp/producer/bean/EmployeeBean.java: -------------------------------------------------------------------------------- 1 | package com.app.emp.producer.bean; 2 | 3 | import java.io.Serializable; 4 | 5 | public class EmployeeBean implements Serializable{ 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private String userId; 10 | private String name; 11 | 12 | public String getUserId() { 13 | return userId; 14 | } 15 | public void setUserId(String userId) { 16 | this.userId = userId; 17 | } 18 | public String getName() { 19 | return name; 20 | } 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "Employee [userId=" + userId + ", name=" + name + "]"; 28 | } 29 | 30 | public EmployeeBean() { 31 | // TODO Auto-generated constructor stub 32 | } 33 | 34 | public EmployeeBean(String userId, String name) { 35 | super(); 36 | this.userId = userId; 37 | this.name = name; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /EmployeeProducerService/src/main/java/com/app/emp/producer/controller/EmployeeController.java: -------------------------------------------------------------------------------- 1 | package com.app.emp.producer.controller; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.CrossOrigin; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import com.app.emp.producer.bean.EmployeeBean; 12 | import com.app.emp.producer.dao.EmployeeRepository; 13 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; 14 | /* 15 | Commented as its been called from Zuul Gateway Service 16 | Uncomment if to call directly 17 | @CrossOrigin 18 | 19 | */ 20 | @RestController 21 | public class EmployeeController { 22 | 23 | @Autowired 24 | EmployeeRepository profileRepository; 25 | 26 | @RequestMapping("/profiles") 27 | public EmployeeBean[] all() { 28 | List profiles = profileRepository.getAllProfiles(); 29 | return profiles.toArray(new EmployeeBean[profiles.size()]); 30 | } 31 | 32 | @RequestMapping("/profiles/{id}") 33 | // @HystrixCommand(fallbackMethod = "getDefaultProfile") 34 | // This currently works only in a class marked with @Component or @Service 35 | public EmployeeBean byId(@PathVariable("id") String userId) { 36 | EmployeeBean employeeBean = profileRepository.getProfile(userId); 37 | return employeeBean; 38 | } 39 | 40 | /* 41 | * public EmployeeBean getDefaultProfile(String userId) { EmployeeBean 42 | * employeeBean = new EmployeeBean("0000", "No employee"); return employeeBean; 43 | * } 44 | */ 45 | } 46 | -------------------------------------------------------------------------------- /EmployeeProducerService/src/main/java/com/app/emp/producer/dao/EmployeeRepository.java: -------------------------------------------------------------------------------- 1 | package com.app.emp.producer.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.app.emp.producer.bean.EmployeeBean; 6 | 7 | 8 | public interface EmployeeRepository { 9 | 10 | List getAllProfiles(); 11 | EmployeeBean getProfile(String userId); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /EmployeeProducerService/src/main/java/com/app/emp/producer/dao/EmployeeRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package com.app.emp.producer.dao; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.springframework.stereotype.Repository; 9 | 10 | import com.app.emp.producer.bean.EmployeeBean; 11 | 12 | @Repository 13 | public class EmployeeRepositoryImpl implements EmployeeRepository { 14 | 15 | private Map empData = new HashMap(); 16 | 17 | public EmployeeRepositoryImpl() { 18 | EmployeeBean emp = new EmployeeBean("1000", "Vincent"); 19 | empData.put("1000", emp); 20 | emp = new EmployeeBean("2000", "Harry"); 21 | empData.put("2000", emp); 22 | emp = new EmployeeBean("3000", "Clark"); 23 | empData.put("3000", emp); 24 | emp = new EmployeeBean("4000", "Stephen"); 25 | empData.put("4000", emp); 26 | } 27 | 28 | @Override 29 | public List getAllProfiles() { 30 | return new ArrayList(empData.values()); 31 | } 32 | 33 | @Override 34 | public EmployeeBean getProfile(String userId) { 35 | return empData.get(userId); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /EmployeeProducerService/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: employee-microservice-dataset 4 | 5 | # Discovery Server Access 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://localhost:8761/eureka/ 10 | 11 | # HTTP Server (Tomcat) Port 12 | server: 13 | port: 8097 14 | 15 | management: 16 | endpoints: 17 | web: 18 | exposure: 19 | include: health,info,hystrix.stream 20 | 21 | # Disable Spring Boot's "Whitelabel" default error page, so we can use our own 22 | error: 23 | whitelabel: 24 | enabled: false -------------------------------------------------------------------------------- /EmployeeProducerService/src/test/java/com/app/service/EmployeeProducerServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.app.service; 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 EmployeeProducerServiceApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /EurekaServerProj/.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/ 26 | /bin/ 27 | -------------------------------------------------------------------------------- /EurekaServerProj/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamtech/SpringBoot-Microservice-Eurka-Zuul/b232aed6c5ddd16913a934a80845c95d9d18067d/EurekaServerProj/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /EurekaServerProj/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /EurekaServerProj/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | VOLUME /tmp 3 | ADD target/EurekaServerProj-0.0.1-SNAPSHOT.jar EurekaServerProj.jar 4 | RUN bash -c 'touch /EurekaServerProj.jar' 5 | ENV JAVA_OPTS="" 6 | ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /EurekaServerProj.jar"] -------------------------------------------------------------------------------- /EurekaServerProj/README.md: -------------------------------------------------------------------------------- 1 | # EurekaServerProj 2 | 3 | ### Spring Eureka Dashboard URL: 4 | http://localhost:8761/ 5 | -------------------------------------------------------------------------------- /EurekaServerProj/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Migwn, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | echo $MAVEN_PROJECTBASEDIR 205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 206 | 207 | # For Cygwin, switch paths to Windows format before running java 208 | if $cygwin; then 209 | [ -n "$M2_HOME" ] && 210 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 211 | [ -n "$JAVA_HOME" ] && 212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 213 | [ -n "$CLASSPATH" ] && 214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 215 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 217 | fi 218 | 219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 220 | 221 | exec "$JAVACMD" \ 222 | $MAVEN_OPTS \ 223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 226 | -------------------------------------------------------------------------------- /EurekaServerProj/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 | -------------------------------------------------------------------------------- /EurekaServerProj/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | EurekaServerProj 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | EurekaServerProj 12 | Demo project for Eureka Server 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.3.10.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | Hoxton.SR11 26 | 27 | 28 | 29 | 30 | org.springframework.cloud 31 | spring-cloud-starter-netflix-eureka-client 32 | 33 | 34 | org.springframework.cloud 35 | spring-cloud-starter-netflix-eureka-server 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.springframework.cloud 49 | spring-cloud-dependencies 50 | ${spring-cloud.version} 51 | pom 52 | import 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-maven-plugin 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /EurekaServerProj/src/main/java/com/app/service/EurekaServerProjApplication.java: -------------------------------------------------------------------------------- 1 | package com.app.service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @EnableEurekaServer 8 | @SpringBootApplication 9 | public class EurekaServerProjApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaServerProjApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /EurekaServerProj/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8761 2 | eureka.client.register-with-eureka=false 3 | eureka.client.fetchRegistry=false 4 | 5 | -------------------------------------------------------------------------------- /EurekaServerProj/src/test/java/com/app/service/EurekaServerProjApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.app.service; 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 EurekaServerProjApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /GatewayServerZuul/.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 | ### Maven ### 14 | .mvn 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /build/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ -------------------------------------------------------------------------------- /GatewayServerZuul/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamtech/SpringBoot-Microservice-Eurka-Zuul/b232aed6c5ddd16913a934a80845c95d9d18067d/GatewayServerZuul/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /GatewayServerZuul/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /GatewayServerZuul/README.md: -------------------------------------------------------------------------------- 1 | # Gateway server for Intelligent Routing [for Request form UI] 2 | 3 | Here endpoint of service **employee-microservice-dataset** is being called via this Gateway server *(check bootstrap.yml)*. 4 | Example: 5 | 6 | 7 | `http://localhost:8093/employeeUI/profiles 8 | ` 9 | 10 | ### Using JWT Token 11 | 12 | *Step 1* - `POST request to http://localhost:8093/auth` 13 | with 14 | 15 | JSON: 16 | { 17 | "username": "admin", 18 | "password": "admin" 19 | } 20 | 21 | 22 | `This will retun a JWT token like : eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTU0MTA1NTY1MiwiaWF0IjoxNTQwNDUwODUyfQ.2QCp1ZNXAokmLRl5-UdRw9mr3vqdBPZwLnoBv87OeGT9fqMhtYZTbtAiHITq-yWjCdC-XNwEEJ_Aq-vG_9u3kg` 23 | 24 | *Step 2* - `GET request to http://localhost:8093/employeeUI/profiles` 25 | with header 26 | 27 | Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTU0MTA1NTY1MiwiaWF0IjoxNTQwNDUwODUyfQ.2QCp1ZNXAokmLRl5-UdRw9mr3vqdBPZwLnoBv87OeGT9fqMhtYZTbtAiHITq-yWjCdC-XNwEEJ_Aq-vG_9u3kg 28 | 29 | 30 | 31 | ### Custom Actuator End Point 32 | `GET request to http://localhost:8093/actuator/info` 33 | 34 | This will produce: 35 | ``` 36 | { 37 | "app": { 38 | "name": "Gateway Application Version 1.0", 39 | "java": { 40 | "version": 1.8 41 | }, 42 | "type": "ZULL Gateway in Spring Boot" 43 | } 44 | } 45 | ``` 46 | -------------------------------------------------------------------------------- /GatewayServerZuul/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Migwn, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | echo $MAVEN_PROJECTBASEDIR 205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 206 | 207 | # For Cygwin, switch paths to Windows format before running java 208 | if $cygwin; then 209 | [ -n "$M2_HOME" ] && 210 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 211 | [ -n "$JAVA_HOME" ] && 212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 213 | [ -n "$CLASSPATH" ] && 214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 215 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 217 | fi 218 | 219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 220 | 221 | exec "$JAVACMD" \ 222 | $MAVEN_OPTS \ 223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 226 | -------------------------------------------------------------------------------- /GatewayServerZuul/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 | -------------------------------------------------------------------------------- /GatewayServerZuul/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | GatewayServerZuul 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | GatewayServerZuul 12 | Configuration Service For Employee Services 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.3.10.RELEASE 18 | 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | Hoxton.SR11 27 | 0.9.1 28 | 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-web 34 | 35 | 36 | org.springframework.cloud 37 | spring-cloud-starter-netflix-eureka-client 38 | 39 | 40 | org.springframework.cloud 41 | spring-cloud-starter-netflix-zuul 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter-actuator 47 | 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-starter-test 52 | 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-starter-security 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-starter-data-jpa 62 | 63 | 64 | 65 | com.h2database 66 | h2 67 | runtime 68 | 69 | 70 | 71 | io.jsonwebtoken 72 | jjwt 73 | ${jjwt.version} 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | org.springframework.cloud 82 | spring-cloud-dependencies 83 | ${spring-cloud.version} 84 | pom 85 | import 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | org.springframework.boot 94 | spring-boot-maven-plugin 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/GatewayServerZuulApplication.java: -------------------------------------------------------------------------------- 1 | package com.app.services; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.web.cors.CorsConfiguration; 9 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; 10 | import org.springframework.web.filter.CorsFilter; 11 | 12 | import com.app.services.filters.ErrorFilter; 13 | import com.app.services.filters.PostFilter; 14 | import com.app.services.filters.PreFilter; 15 | import com.app.services.filters.RouteFilter; 16 | 17 | @EnableZuulProxy 18 | @SpringBootApplication 19 | @EnableDiscoveryClient 20 | public class GatewayServerZuulApplication { 21 | 22 | public static void main(String[] args) { 23 | SpringApplication.run(GatewayServerZuulApplication.class, args); 24 | } 25 | 26 | @Bean 27 | public PreFilter preFilter() { 28 | return new PreFilter(); 29 | } 30 | @Bean 31 | public PostFilter postFilter() { 32 | return new PostFilter(); 33 | } 34 | @Bean 35 | public ErrorFilter errorFilter() { 36 | return new ErrorFilter(); 37 | } 38 | @Bean 39 | public RouteFilter routeFilter() { 40 | return new RouteFilter(); 41 | } 42 | 43 | @Bean 44 | public CorsFilter corsFilter() { 45 | final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 46 | final CorsConfiguration config = new CorsConfiguration(); 47 | config.setAllowCredentials(true); 48 | config.addAllowedOrigin("*"); 49 | config.addAllowedHeader("*"); 50 | config.addAllowedMethod("OPTIONS"); 51 | config.addAllowedMethod("HEAD"); 52 | config.addAllowedMethod("GET"); 53 | config.addAllowedMethod("PUT"); 54 | config.addAllowedMethod("POST"); 55 | config.addAllowedMethod("DELETE"); 56 | config.addAllowedMethod("PATCH"); 57 | source.registerCorsConfiguration("/**", config); 58 | return new CorsFilter(source); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/filters/ErrorFilter.java: -------------------------------------------------------------------------------- 1 | package com.app.services.filters; 2 | 3 | import com.netflix.zuul.ZuulFilter; 4 | 5 | public class ErrorFilter extends ZuulFilter { 6 | 7 | @Override 8 | public String filterType() { 9 | return "error"; 10 | } 11 | 12 | @Override 13 | public int filterOrder() { 14 | return 1; 15 | } 16 | 17 | @Override 18 | public boolean shouldFilter() { 19 | return true; 20 | } 21 | 22 | @Override 23 | public Object run() { 24 | System.out.println("Inside Route Filter"); 25 | 26 | return null; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/filters/PostFilter.java: -------------------------------------------------------------------------------- 1 | package com.app.services.filters; 2 | 3 | import com.netflix.zuul.ZuulFilter; 4 | 5 | public class PostFilter extends ZuulFilter { 6 | 7 | @Override 8 | public String filterType() { 9 | return "post"; 10 | } 11 | 12 | @Override 13 | public int filterOrder() { 14 | return 1; 15 | } 16 | 17 | @Override 18 | public boolean shouldFilter() { 19 | return true; 20 | } 21 | 22 | @Override 23 | public Object run() { 24 | System.out.println("Inside Response Filter"); 25 | 26 | return null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/filters/PreFilter.java: -------------------------------------------------------------------------------- 1 | package com.app.services.filters; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import com.netflix.zuul.ZuulFilter; 5 | import com.netflix.zuul.context.RequestContext; 6 | 7 | public class PreFilter extends ZuulFilter { 8 | 9 | @Override 10 | public String filterType() { 11 | return "pre"; 12 | } 13 | 14 | @Override 15 | public int filterOrder() { 16 | return 1; 17 | } 18 | 19 | @Override 20 | public boolean shouldFilter() { 21 | return true; 22 | } 23 | 24 | @Override 25 | public Object run() { 26 | RequestContext ctx = RequestContext.getCurrentContext(); 27 | HttpServletRequest request = ctx.getRequest(); 28 | 29 | System.out.println("Request Method : " + request.getMethod() + " Request URL : " + request.getRequestURL().toString()); 30 | return null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/filters/RouteFilter.java: -------------------------------------------------------------------------------- 1 | package com.app.services.filters; 2 | 3 | import com.netflix.zuul.ZuulFilter; 4 | 5 | public class RouteFilter extends ZuulFilter { 6 | 7 | @Override 8 | public String filterType() { 9 | return "route"; 10 | } 11 | 12 | @Override 13 | public int filterOrder() { 14 | return 1; 15 | } 16 | 17 | @Override 18 | public boolean shouldFilter() { 19 | return true; 20 | } 21 | 22 | @Override 23 | public Object run() { 24 | System.out.println("Inside Route Filter"); 25 | return null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/model/Authority.java: -------------------------------------------------------------------------------- 1 | package com.app.services.model; 2 | 3 | import javax.persistence.*; 4 | import javax.validation.constraints.NotNull; 5 | import java.util.List; 6 | 7 | @Entity 8 | @Table(name = "AUTHORITY") 9 | public class Authority { 10 | 11 | @Id 12 | @Column(name = "ID") 13 | @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "authority_seq") 14 | @SequenceGenerator(name = "authority_seq", sequenceName = "authority_seq", allocationSize = 1) 15 | private Long id; 16 | 17 | @Column(name = "NAME", length = 50) 18 | @NotNull 19 | @Enumerated(EnumType.STRING) 20 | private AuthorityName name; 21 | 22 | @ManyToMany(mappedBy = "authorities", fetch = FetchType.LAZY) 23 | private List users; 24 | 25 | public Long getId() { 26 | return id; 27 | } 28 | 29 | public void setId(Long id) { 30 | this.id = id; 31 | } 32 | 33 | public AuthorityName getName() { 34 | return name; 35 | } 36 | 37 | public void setName(AuthorityName name) { 38 | this.name = name; 39 | } 40 | 41 | public List getUsers() { 42 | return users; 43 | } 44 | 45 | public void setUsers(List users) { 46 | this.users = users; 47 | } 48 | } -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/model/AuthorityName.java: -------------------------------------------------------------------------------- 1 | package com.app.services.model; 2 | 3 | public enum AuthorityName { 4 | ROLE_USER, ROLE_ADMIN 5 | } -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/model/User.java: -------------------------------------------------------------------------------- 1 | package com.app.services.model; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import javax.persistence.Column; 7 | import javax.persistence.Entity; 8 | import javax.persistence.FetchType; 9 | import javax.persistence.GeneratedValue; 10 | import javax.persistence.GenerationType; 11 | import javax.persistence.Id; 12 | import javax.persistence.JoinColumn; 13 | import javax.persistence.JoinTable; 14 | import javax.persistence.ManyToMany; 15 | import javax.persistence.SequenceGenerator; 16 | import javax.persistence.Table; 17 | import javax.persistence.Temporal; 18 | import javax.persistence.TemporalType; 19 | import javax.validation.constraints.NotNull; 20 | import javax.validation.constraints.Size; 21 | 22 | @Entity 23 | @Table(name = "USER") 24 | public class User { 25 | 26 | @Id 27 | @Column(name = "ID") 28 | @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_seq") 29 | @SequenceGenerator(name = "user_seq", sequenceName = "user_seq", allocationSize = 1) 30 | private Long id; 31 | 32 | @Column(name = "USERNAME", length = 50, unique = true) 33 | @NotNull 34 | @Size(min = 4, max = 50) 35 | private String username; 36 | 37 | @Column(name = "PASSWORD", length = 100) 38 | @NotNull 39 | @Size(min = 4, max = 100) 40 | private String password; 41 | 42 | @Column(name = "FIRSTNAME", length = 50) 43 | @NotNull 44 | @Size(min = 4, max = 50) 45 | private String firstname; 46 | 47 | @Column(name = "LASTNAME", length = 50) 48 | @NotNull 49 | @Size(min = 4, max = 50) 50 | private String lastname; 51 | 52 | @Column(name = "EMAIL", length = 50) 53 | @NotNull 54 | @Size(min = 4, max = 50) 55 | private String email; 56 | 57 | @Column(name = "ENABLED") 58 | @NotNull 59 | private Boolean enabled; 60 | 61 | @Column(name = "LASTPASSWORDRESETDATE") 62 | @Temporal(TemporalType.TIMESTAMP) 63 | @NotNull 64 | private Date lastPasswordResetDate; 65 | 66 | @ManyToMany(fetch = FetchType.EAGER) 67 | @JoinTable( 68 | name = "USER_AUTHORITY", 69 | joinColumns = {@JoinColumn(name = "USER_ID", referencedColumnName = "ID")}, 70 | inverseJoinColumns = {@JoinColumn(name = "AUTHORITY_ID", referencedColumnName = "ID")}) 71 | private List authorities; 72 | 73 | public Long getId() { 74 | return id; 75 | } 76 | 77 | public void setId(Long id) { 78 | this.id = id; 79 | } 80 | 81 | public String getUsername() { 82 | return username; 83 | } 84 | 85 | public void setUsername(String username) { 86 | this.username = username; 87 | } 88 | 89 | public String getPassword() { 90 | return password; 91 | } 92 | 93 | public void setPassword(String password) { 94 | this.password = password; 95 | } 96 | 97 | public String getFirstname() { 98 | return firstname; 99 | } 100 | 101 | public void setFirstname(String firstname) { 102 | this.firstname = firstname; 103 | } 104 | 105 | public String getLastname() { 106 | return lastname; 107 | } 108 | 109 | public void setLastname(String lastname) { 110 | this.lastname = lastname; 111 | } 112 | 113 | public String getEmail() { 114 | return email; 115 | } 116 | 117 | public void setEmail(String email) { 118 | this.email = email; 119 | } 120 | 121 | public Boolean getEnabled() { 122 | return enabled; 123 | } 124 | 125 | public void setEnabled(Boolean enabled) { 126 | this.enabled = enabled; 127 | } 128 | 129 | public List getAuthorities() { 130 | return authorities; 131 | } 132 | 133 | public void setAuthorities(List authorities) { 134 | this.authorities = authorities; 135 | } 136 | 137 | public Date getLastPasswordResetDate() { 138 | return lastPasswordResetDate; 139 | } 140 | 141 | public void setLastPasswordResetDate(Date lastPasswordResetDate) { 142 | this.lastPasswordResetDate = lastPasswordResetDate; 143 | } 144 | } -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/JwtAuthenticationEntryPoint.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security; 2 | 3 | import java.io.IOException; 4 | import java.io.Serializable; 5 | 6 | import javax.servlet.ServletException; 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | 10 | import org.springframework.security.core.AuthenticationException; 11 | import org.springframework.security.web.AuthenticationEntryPoint; 12 | import org.springframework.stereotype.Component; 13 | 14 | @Component 15 | public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable { 16 | 17 | private static final long serialVersionUID = -8970718410437077606L; 18 | 19 | @Override 20 | public void commence(HttpServletRequest request, 21 | HttpServletResponse response, 22 | AuthenticationException authException) throws IOException,ServletException { 23 | // This is invoked when user tries to access a secured REST resource without supplying any credentials 24 | // We should just send a 401 Unauthorized response because there is no 'login page' to redirect to 25 | response.setContentType("application/json"); 26 | response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); 27 | response.getOutputStream().println("{ \"error\": \"" + authException.getMessage() + "\" }"); 28 | } 29 | } -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/JwtAuthenticationRequest.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by stephan on 20.03.16. 7 | */ 8 | public class JwtAuthenticationRequest implements Serializable { 9 | 10 | private static final long serialVersionUID = -8445943548965154778L; 11 | 12 | private String username; 13 | private String password; 14 | 15 | public JwtAuthenticationRequest() { 16 | super(); 17 | } 18 | 19 | public JwtAuthenticationRequest(String username, String password) { 20 | this.setUsername(username); 21 | this.setPassword(password); 22 | } 23 | 24 | public String getUsername() { 25 | return this.username; 26 | } 27 | 28 | public void setUsername(String username) { 29 | this.username = username; 30 | } 31 | 32 | public String getPassword() { 33 | return this.password; 34 | } 35 | 36 | public void setPassword(String password) { 37 | this.password = password; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/JwtAuthorizationTokenFilter.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.FilterChain; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.beans.factory.annotation.Value; 13 | import org.springframework.http.HttpStatus; 14 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 15 | import org.springframework.security.core.context.SecurityContextHolder; 16 | import org.springframework.security.core.userdetails.UserDetails; 17 | import org.springframework.security.core.userdetails.UserDetailsService; 18 | import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; 19 | import org.springframework.stereotype.Component; 20 | import org.springframework.web.filter.OncePerRequestFilter; 21 | 22 | import com.fasterxml.jackson.core.JsonProcessingException; 23 | import com.fasterxml.jackson.databind.ObjectMapper; 24 | 25 | import io.jsonwebtoken.ExpiredJwtException; 26 | 27 | @Component 28 | public class JwtAuthorizationTokenFilter extends OncePerRequestFilter { 29 | 30 | private final Logger logger = LoggerFactory.getLogger(this.getClass()); 31 | 32 | private final UserDetailsService userDetailsService; 33 | private final JwtTokenUtil jwtTokenUtil; 34 | private final String tokenHeader; 35 | 36 | public JwtAuthorizationTokenFilter(UserDetailsService userDetailsService, JwtTokenUtil jwtTokenUtil, @Value("${jwt.header}") String tokenHeader) { 37 | this.userDetailsService = userDetailsService; 38 | this.jwtTokenUtil = jwtTokenUtil; 39 | this.tokenHeader = tokenHeader; 40 | } 41 | 42 | @Override 43 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { 44 | logger.debug("processing authentication for '{}'", request.getRequestURL()); 45 | try{ 46 | final String requestHeader = request.getHeader(this.tokenHeader); 47 | 48 | String username = null; 49 | String authToken = null; 50 | if (requestHeader != null && requestHeader.startsWith("Bearer ")) { 51 | authToken = requestHeader.substring(7); 52 | try { 53 | username = jwtTokenUtil.getUsernameFromToken(authToken); 54 | } catch (IllegalArgumentException e) { 55 | logger.error("an error occured during getting username from token", e); 56 | } catch (ExpiredJwtException e) { 57 | logger.warn("the token is expired and not valid anymore", e); 58 | } 59 | } else { 60 | logger.warn("couldn't find bearer string, will ignore the header"); 61 | } 62 | 63 | logger.debug("checking authentication for user '{}'", username); 64 | if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) { 65 | logger.debug("security context was null, so authorizating user"); 66 | 67 | // It is not compelling necessary to load the use details from the database. You could also store the information 68 | // in the token and read it from it. It's up to you ;) 69 | UserDetails userDetails = this.userDetailsService.loadUserByUsername(username); 70 | 71 | // For simple validation it is completely sufficient to just check the token integrity. You don't have to call 72 | // the database compellingly. Again it's up to you ;) 73 | if (jwtTokenUtil.validateToken(authToken, userDetails)) { 74 | UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); 75 | authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); 76 | logger.info("authorizated user '{}', setting security context", username); 77 | SecurityContextHolder.getContext().setAuthentication(authentication); 78 | } 79 | } 80 | }catch (Exception e) { 81 | logger.info("Authorization Error:"+e.getMessage()); 82 | // response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); 83 | response.sendError(HttpServletResponse.SC_FORBIDDEN, "Unauthorized User"); 84 | return; 85 | } 86 | 87 | chain.doFilter(request, response); 88 | } 89 | 90 | public String convertObjectToJson(Object object) throws JsonProcessingException { 91 | if (object == null) { 92 | return null; 93 | } 94 | ObjectMapper mapper = new ObjectMapper(); 95 | return mapper.writeValueAsString(object); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/JwtTokenUtil.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import java.util.function.Function; 8 | import java.util.stream.Collectors; 9 | 10 | import org.springframework.beans.factory.annotation.Value; 11 | import org.springframework.security.core.userdetails.UserDetails; 12 | import org.springframework.stereotype.Component; 13 | 14 | import io.jsonwebtoken.Claims; 15 | import io.jsonwebtoken.Clock; 16 | import io.jsonwebtoken.Jwts; 17 | import io.jsonwebtoken.SignatureAlgorithm; 18 | import io.jsonwebtoken.impl.DefaultClock; 19 | 20 | @Component 21 | public class JwtTokenUtil implements Serializable { 22 | 23 | static final String CLAIM_KEY_USERNAME = "sub"; 24 | static final String CLAIM_KEY_CREATED = "iat"; 25 | private static final long serialVersionUID = -3301605591108950415L; 26 | // @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "It's okay here") 27 | private Clock clock = DefaultClock.INSTANCE; 28 | 29 | @Value("${jwt.secret}") 30 | private String secret; 31 | 32 | @Value("${jwt.expiration}") 33 | private Long expiration; 34 | 35 | public String getUsernameFromToken(String token) { 36 | return getClaimFromToken(token, Claims::getSubject); 37 | } 38 | 39 | public Date getIssuedAtDateFromToken(String token) { 40 | return getClaimFromToken(token, Claims::getIssuedAt); 41 | } 42 | 43 | public Date getExpirationDateFromToken(String token) { 44 | return getClaimFromToken(token, Claims::getExpiration); 45 | } 46 | 47 | public T getClaimFromToken(String token, Function claimsResolver) { 48 | final Claims claims = getAllClaimsFromToken(token); 49 | return claimsResolver.apply(claims); 50 | } 51 | 52 | private Claims getAllClaimsFromToken(String token) { 53 | return Jwts.parser() 54 | .setSigningKey(secret) 55 | .parseClaimsJws(token) 56 | .getBody(); 57 | } 58 | 59 | private Boolean isTokenExpired(String token) { 60 | final Date expiration = getExpirationDateFromToken(token); 61 | return expiration.before(clock.now()); 62 | } 63 | 64 | private Boolean isCreatedBeforeLastPasswordReset(Date created, Date lastPasswordReset) { 65 | return (lastPasswordReset != null && created.before(lastPasswordReset)); 66 | } 67 | 68 | private Boolean ignoreTokenExpiration(String token) { 69 | // here you specify tokens, for that the expiration is ignored 70 | return false; 71 | } 72 | 73 | public String generateToken(UserDetails userDetails) { 74 | Map claims = new HashMap<>(); 75 | claims.put("scopes", userDetails.getAuthorities().stream().map(s -> s.toString()).collect(Collectors.toList())); 76 | return doGenerateToken(claims, userDetails.getUsername()); 77 | } 78 | 79 | private String doGenerateToken(Map claims, String subject) { 80 | final Date createdDate = clock.now(); 81 | final Date expirationDate = calculateExpirationDate(createdDate); 82 | 83 | return Jwts.builder() 84 | .setClaims(claims) 85 | .setSubject(subject) 86 | .setIssuedAt(createdDate) 87 | .setExpiration(expirationDate) 88 | .signWith(SignatureAlgorithm.HS512, secret) 89 | .compact(); 90 | } 91 | 92 | public Boolean canTokenBeRefreshed(String token, Date lastPasswordReset) { 93 | final Date created = getIssuedAtDateFromToken(token); 94 | return !isCreatedBeforeLastPasswordReset(created, lastPasswordReset) 95 | && (!isTokenExpired(token) || ignoreTokenExpiration(token)); 96 | } 97 | 98 | public String refreshToken(String token) { 99 | final Date createdDate = clock.now(); 100 | final Date expirationDate = calculateExpirationDate(createdDate); 101 | 102 | final Claims claims = getAllClaimsFromToken(token); 103 | claims.setIssuedAt(createdDate); 104 | claims.setExpiration(expirationDate); 105 | 106 | return Jwts.builder() 107 | .setClaims(claims) 108 | .signWith(SignatureAlgorithm.HS512, secret) 109 | .compact(); 110 | } 111 | 112 | public Boolean validateToken(String token, UserDetails userDetails) { 113 | JwtUser user = (JwtUser) userDetails; 114 | final String username = getUsernameFromToken(token); 115 | final Date created = getIssuedAtDateFromToken(token); 116 | //final Date expiration = getExpirationDateFromToken(token); 117 | return ( 118 | username.equals(user.getUsername()) 119 | && !isTokenExpired(token) 120 | && !isCreatedBeforeLastPasswordReset(created, user.getLastPasswordResetDate()) 121 | ); 122 | } 123 | 124 | private Date calculateExpirationDate(Date createdDate) { 125 | return new Date(createdDate.getTime() + expiration * 1000); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/JwtUser.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security; 2 | 3 | import java.util.Collection; 4 | import java.util.Date; 5 | 6 | import org.springframework.security.core.GrantedAuthority; 7 | import org.springframework.security.core.userdetails.UserDetails; 8 | 9 | import com.fasterxml.jackson.annotation.JsonIgnore; 10 | 11 | /** 12 | * Created by stephan on 20.03.16. 13 | */ 14 | public class JwtUser implements UserDetails { 15 | 16 | private final Long id; 17 | private final String username; 18 | private final String firstname; 19 | private final String lastname; 20 | private final String password; 21 | private final String email; 22 | private final Collection authorities; 23 | private final boolean enabled; 24 | private final Date lastPasswordResetDate; 25 | 26 | public JwtUser( 27 | Long id, 28 | String username, 29 | String firstname, 30 | String lastname, 31 | String email, 32 | String password, Collection authorities, 33 | boolean enabled, 34 | Date lastPasswordResetDate 35 | ) { 36 | this.id = id; 37 | this.username = username; 38 | this.firstname = firstname; 39 | this.lastname = lastname; 40 | this.email = email; 41 | this.password = password; 42 | this.authorities = authorities; 43 | this.enabled = enabled; 44 | this.lastPasswordResetDate = lastPasswordResetDate; 45 | } 46 | 47 | @JsonIgnore 48 | public Long getId() { 49 | return id; 50 | } 51 | 52 | @Override 53 | public String getUsername() { 54 | return username; 55 | } 56 | 57 | @JsonIgnore 58 | @Override 59 | public boolean isAccountNonExpired() { 60 | return true; 61 | } 62 | 63 | @JsonIgnore 64 | @Override 65 | public boolean isAccountNonLocked() { 66 | return true; 67 | } 68 | 69 | @JsonIgnore 70 | @Override 71 | public boolean isCredentialsNonExpired() { 72 | return true; 73 | } 74 | 75 | public String getFirstname() { 76 | return firstname; 77 | } 78 | 79 | public String getLastname() { 80 | return lastname; 81 | } 82 | 83 | public String getEmail() { 84 | return email; 85 | } 86 | 87 | @JsonIgnore 88 | @Override 89 | public String getPassword() { 90 | return password; 91 | } 92 | 93 | @Override 94 | public Collection getAuthorities() { 95 | return authorities; 96 | } 97 | 98 | @Override 99 | public boolean isEnabled() { 100 | return enabled; 101 | } 102 | 103 | @JsonIgnore 104 | public Date getLastPasswordResetDate() { 105 | return lastPasswordResetDate; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/JwtUserFactory.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | 6 | import org.springframework.security.core.GrantedAuthority; 7 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 8 | 9 | import com.app.services.model.Authority; 10 | import com.app.services.model.User; 11 | 12 | public final class JwtUserFactory { 13 | 14 | private JwtUserFactory() { 15 | } 16 | 17 | public static JwtUser create(User user) { 18 | return new JwtUser( 19 | user.getId(), 20 | user.getUsername(), 21 | user.getFirstname(), 22 | user.getLastname(), 23 | user.getEmail(), 24 | user.getPassword(), 25 | mapToGrantedAuthorities(user.getAuthorities()), 26 | user.getEnabled(), 27 | user.getLastPasswordResetDate() 28 | ); 29 | } 30 | 31 | private static List mapToGrantedAuthorities(List authorities) { 32 | return authorities.stream() 33 | .map(authority -> new SimpleGrantedAuthority(authority.getName().name())) 34 | .collect(Collectors.toList()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/config/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security.config; 2 | 3 | import java.util.Arrays; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.http.HttpMethod; 10 | import org.springframework.security.authentication.AuthenticationManager; 11 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 12 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 13 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 14 | import org.springframework.security.config.annotation.web.builders.WebSecurity; 15 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 16 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 17 | import org.springframework.security.config.http.SessionCreationPolicy; 18 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 19 | import org.springframework.security.crypto.password.PasswordEncoder; 20 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 21 | import org.springframework.web.cors.CorsConfiguration; 22 | import org.springframework.web.cors.CorsConfigurationSource; 23 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; 24 | 25 | import com.app.services.security.JwtAuthenticationEntryPoint; 26 | import com.app.services.security.JwtAuthorizationTokenFilter; 27 | import com.app.services.security.service.JwtUserDetailsService; 28 | 29 | @Configuration 30 | @EnableWebSecurity 31 | @EnableGlobalMethodSecurity(prePostEnabled = true) 32 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 33 | 34 | @Autowired 35 | private JwtAuthenticationEntryPoint unauthorizedHandler; 36 | 37 | @Autowired 38 | private JwtUserDetailsService jwtUserDetailsService; 39 | 40 | // Custom JWT based security filter 41 | @Autowired 42 | JwtAuthorizationTokenFilter authenticationTokenFilter; 43 | 44 | @Value("${jwt.header}") 45 | private String tokenHeader; 46 | 47 | @Value("${jwt.route.authentication.path}") 48 | private String authenticationPath; 49 | 50 | @Autowired 51 | public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { 52 | auth 53 | .userDetailsService(jwtUserDetailsService) 54 | .passwordEncoder(passwordEncoderBean()); 55 | } 56 | 57 | @Bean 58 | public PasswordEncoder passwordEncoderBean() { 59 | return new BCryptPasswordEncoder(); 60 | } 61 | 62 | @Bean 63 | @Override 64 | public AuthenticationManager authenticationManagerBean() throws Exception { 65 | return super.authenticationManagerBean(); 66 | } 67 | 68 | @Override 69 | protected void configure(HttpSecurity httpSecurity) throws Exception { 70 | httpSecurity 71 | // we don't need CSRF because our token is invulnerable 72 | .csrf().disable() 73 | // enabling Cors api Calls 74 | .cors().and() 75 | .exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and() 76 | 77 | // don't create session 78 | .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() 79 | 80 | .authorizeRequests() 81 | 82 | // Un-secure H2 Database 83 | .antMatchers("/h2-console/**/**").permitAll() 84 | 85 | .antMatchers("/auth/**").permitAll() 86 | 87 | //Allow Actuator EndPoints 88 | .antMatchers("/actuator/**").permitAll() 89 | // Only for ADMIN scope User 90 | .antMatchers("/employeeUI/**").hasRole("ADMIN") 91 | .anyRequest().authenticated(); 92 | 93 | httpSecurity 94 | .addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class); 95 | 96 | // disable page caching 97 | httpSecurity 98 | .headers() 99 | .frameOptions().sameOrigin() // required to set for H2 else H2 Console will be blank. 100 | .cacheControl(); 101 | } 102 | 103 | @Override 104 | public void configure(WebSecurity web) throws Exception { 105 | // AuthenticationTokenFilter will ignore the below paths 106 | web 107 | .ignoring() 108 | .antMatchers( 109 | HttpMethod.POST, 110 | authenticationPath 111 | ) 112 | 113 | // allow anonymous resource requests 114 | .and() 115 | .ignoring() 116 | .antMatchers( 117 | HttpMethod.GET, 118 | "/", 119 | "/*.html", 120 | "/favicon.ico", 121 | "/**/*.html", 122 | "/**/*.css", 123 | "/**/*.js" 124 | ) 125 | 126 | // Un-secure H2 Database (for testing purposes, H2 console shouldn't be unprotected in production) 127 | .and() 128 | .ignoring() 129 | .antMatchers("/h2-console/**/**"); 130 | 131 | } 132 | 133 | /* @Bean 134 | CorsConfigurationSource corsConfigurationSource() { 135 | CorsConfiguration configuration = new CorsConfiguration(); 136 | configuration.setAllowCredentials(true); 137 | configuration.addAllowedOrigin("*"); 138 | configuration.addAllowedHeader("*"); 139 | configuration.setAllowedMethods(Arrays.asList("GET","POST")); 140 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 141 | source.registerCorsConfiguration("/**", configuration); 142 | return source; 143 | }*/ 144 | } 145 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/controller/AuthenticationException.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security.controller; 2 | 3 | public class AuthenticationException extends RuntimeException { 4 | public AuthenticationException(String message, Throwable cause) { 5 | super(message, cause); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/controller/AuthenticationRestController.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security.controller; 2 | 3 | import java.util.Objects; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.beans.factory.annotation.Qualifier; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.security.authentication.AuthenticationManager; 13 | import org.springframework.security.authentication.BadCredentialsException; 14 | import org.springframework.security.authentication.DisabledException; 15 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 16 | import org.springframework.security.core.userdetails.UserDetails; 17 | import org.springframework.security.core.userdetails.UserDetailsService; 18 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 19 | import org.springframework.web.bind.annotation.CrossOrigin; 20 | import org.springframework.web.bind.annotation.ExceptionHandler; 21 | import org.springframework.web.bind.annotation.RequestBody; 22 | import org.springframework.web.bind.annotation.RequestMapping; 23 | import org.springframework.web.bind.annotation.RequestMethod; 24 | import org.springframework.web.bind.annotation.RestController; 25 | 26 | import com.app.services.security.JwtAuthenticationRequest; 27 | import com.app.services.security.JwtTokenUtil; 28 | import com.app.services.security.JwtUser; 29 | import com.app.services.security.service.JwtAuthenticationResponse; 30 | 31 | @CrossOrigin 32 | @RestController 33 | public class AuthenticationRestController { 34 | 35 | @Value("${jwt.header}") 36 | private String tokenHeader; 37 | 38 | @Autowired 39 | private AuthenticationManager authenticationManager; 40 | 41 | @Autowired 42 | private JwtTokenUtil jwtTokenUtil; 43 | 44 | @Autowired 45 | @Qualifier("jwtUserDetailsService") 46 | private UserDetailsService userDetailsService; 47 | 48 | @RequestMapping(value = "${jwt.route.authentication.path}", method = RequestMethod.POST) 49 | public ResponseEntity createAuthenticationToken(@RequestBody JwtAuthenticationRequest authenticationRequest) throws AuthenticationException { 50 | 51 | authenticate(authenticationRequest.getUsername(), authenticationRequest.getPassword()); 52 | 53 | // Reload password post-security so we can generate the token 54 | final UserDetails userDetails = userDetailsService.loadUserByUsername(authenticationRequest.getUsername()); 55 | final String token = jwtTokenUtil.generateToken(userDetails); 56 | 57 | // Return the token 58 | return ResponseEntity.ok(new JwtAuthenticationResponse(token)); 59 | } 60 | 61 | @RequestMapping(value = "${jwt.route.authentication.refresh}", method = RequestMethod.GET) 62 | public ResponseEntity refreshAndGetAuthenticationToken(HttpServletRequest request) { 63 | String authToken = request.getHeader(tokenHeader); 64 | final String token = authToken.substring(7); 65 | String username = jwtTokenUtil.getUsernameFromToken(token); 66 | JwtUser user = (JwtUser) userDetailsService.loadUserByUsername(username); 67 | 68 | if (jwtTokenUtil.canTokenBeRefreshed(token, user.getLastPasswordResetDate())) { 69 | String refreshedToken = jwtTokenUtil.refreshToken(token); 70 | return ResponseEntity.ok(new JwtAuthenticationResponse(refreshedToken)); 71 | } else { 72 | return ResponseEntity.badRequest().body(null); 73 | } 74 | } 75 | 76 | @ExceptionHandler({AuthenticationException.class}) 77 | public ResponseEntity handleAuthenticationException(AuthenticationException e) { 78 | return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(e.getMessage()); 79 | } 80 | 81 | /** 82 | * Authenticates the user. If something is wrong, an {@link AuthenticationException} will be thrown 83 | */ 84 | private void authenticate(String username, String password) { 85 | Objects.requireNonNull(username); 86 | Objects.requireNonNull(password); 87 | 88 | try { 89 | /* Generating Bcrypt Password as per Spring Security 90 | * BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); 91 | String hashedPassword = passwordEncoder.encode("userpass");*/ 92 | authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password)); 93 | 94 | } catch (DisabledException e) { 95 | throw new AuthenticationException("User is disabled!", e); 96 | } catch (BadCredentialsException e) { 97 | throw new AuthenticationException("Bad credentials!", e); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/controller/MethodProtectedRestController.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security.controller; 2 | 3 | import org.springframework.http.ResponseEntity; 4 | import org.springframework.security.access.prepost.PreAuthorize; 5 | import org.springframework.web.bind.annotation.CrossOrigin; 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 | @CrossOrigin 11 | @RestController 12 | @RequestMapping("protected") 13 | public class MethodProtectedRestController { 14 | 15 | /** 16 | * This is an example of some different kinds of granular restriction for endpoints. You can use the built-in SPEL expressions 17 | * in @PreAuthorize such as 'hasRole()' to determine if a user has access. Remember that the hasRole expression assumes a 18 | * 'ROLE_' prefix on all role names. So 'ADMIN' here is actually stored as 'ROLE_ADMIN' in database! 19 | **/ 20 | @RequestMapping(method = RequestMethod.GET) 21 | @PreAuthorize("hasRole('ADMIN')") 22 | public ResponseEntity getProtectedGreeting() { 23 | return ResponseEntity.ok("Greetings from admin protected method!"); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/controller/UserRestController.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security.controller; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Qualifier; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.security.core.userdetails.UserDetailsService; 9 | import org.springframework.web.bind.annotation.CrossOrigin; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import com.app.services.security.JwtTokenUtil; 15 | import com.app.services.security.JwtUser; 16 | 17 | @CrossOrigin 18 | @RestController 19 | public class UserRestController { 20 | 21 | @Value("${jwt.header}") 22 | private String tokenHeader; 23 | 24 | @Autowired 25 | private JwtTokenUtil jwtTokenUtil; 26 | 27 | @Autowired 28 | @Qualifier("jwtUserDetailsService") 29 | private UserDetailsService userDetailsService; 30 | 31 | @RequestMapping(value = "user", method = RequestMethod.GET) 32 | public JwtUser getAuthenticatedUser(HttpServletRequest request) { 33 | String token = request.getHeader(tokenHeader).substring(7); 34 | String username = jwtTokenUtil.getUsernameFromToken(token); 35 | JwtUser user = (JwtUser) userDetailsService.loadUserByUsername(username); 36 | return user; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.app.services.model.User; 6 | 7 | /** 8 | * Created by stephan on 20.03.16. 9 | */ 10 | public interface UserRepository extends JpaRepository { 11 | User findByUsername(String username); 12 | } 13 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/service/JwtAuthenticationResponse.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security.service; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by stephan on 20.03.16. 7 | */ 8 | public class JwtAuthenticationResponse implements Serializable { 9 | 10 | private static final long serialVersionUID = 1250166508152483573L; 11 | 12 | private final String token; 13 | 14 | public JwtAuthenticationResponse(String token) { 15 | this.token = token; 16 | } 17 | 18 | public String getToken() { 19 | return this.token; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/java/com/app/services/security/service/JwtUserDetailsService.java: -------------------------------------------------------------------------------- 1 | package com.app.services.security.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.core.userdetails.UserDetails; 5 | import org.springframework.security.core.userdetails.UserDetailsService; 6 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.app.services.model.User; 10 | import com.app.services.security.JwtUserFactory; 11 | import com.app.services.security.repository.UserRepository; 12 | 13 | @Service 14 | public class JwtUserDetailsService implements UserDetailsService { 15 | 16 | @Autowired 17 | private UserRepository userRepository; 18 | 19 | @Override 20 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 21 | User user = userRepository.findByUsername(username); 22 | 23 | if (user == null) { 24 | throw new UsernameNotFoundException(String.format("No user found with username '%s'.", username)); 25 | } else { 26 | return JwtUserFactory.create(user); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: EmployeeAPIGateway 4 | h2: 5 | console: 6 | enabled: true 7 | datasource: 8 | url : jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE 9 | driverClassName : org.h2.Driver 10 | username: sa 11 | password: 12 | jpa: 13 | database-platform: org.hibernate.dialect.H2Dialect 14 | 15 | 16 | eureka: 17 | client: 18 | serviceUrl: 19 | defaultZone : http://localhost:8761/eureka/ 20 | 21 | server: 22 | port : 8093 23 | 24 | security: 25 | basic: 26 | enable : false 27 | 28 | zuul: 29 | routes: 30 | employeeUI: 31 | path: /employeeUI/** 32 | serviceId : employee-microservice-dataset 33 | ticketUI: 34 | path: /ticketUI/** 35 | serviceId : ticket-microservice-dataset 36 | host: 37 | socket-timeout-millis : 30000 38 | 39 | jwt: 40 | header: Authorization 41 | secret: mySecret 42 | expiration: 50000 43 | route: 44 | authentication: 45 | path: /auth 46 | refresh: /refresh 47 | 48 | info: 49 | app: 50 | name: Gateway Application Version 1.0 51 | java: 52 | version: 1.8 53 | type: ZULL Gateway in Spring Boot 54 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO USER (ID, USERNAME, PASSWORD, FIRSTNAME, LASTNAME, EMAIL, ENABLED, LASTPASSWORDRESETDATE) VALUES (1, 'admin', '$2a$08$lDnHPz7eUkSi6ao14Twuau08mzhWrL4kyZGGU5xfiGALO/Vxd5DOi', 'admin', 'admin', 'admin@admin.com', 1, PARSEDATETIME('01-01-2016', 'dd-MM-yyyy')); 2 | INSERT INTO USER (ID, USERNAME, PASSWORD, FIRSTNAME, LASTNAME, EMAIL, ENABLED, LASTPASSWORDRESETDATE) VALUES (2, 'user', '$2a$10$kDSwVLWuP4oXth5sVY23L.NMTRXpjyHWHZuXzynRGFfkqvr3M4ioa', 'user', 'user', 'enabled@user.com', 1, PARSEDATETIME('01-01-2016','dd-MM-yyyy')); 3 | INSERT INTO USER (ID, USERNAME, PASSWORD, FIRSTNAME, LASTNAME, EMAIL, ENABLED, LASTPASSWORDRESETDATE) VALUES (3, 'disabled', '$2a$08$UkVvwpULis18S19S5pZFn.YHPZt3oaqHZnDwqbCW9pft6uFtkXKDC', 'user', 'user', 'disabled@user.com', 0, PARSEDATETIME('01-01-2016','dd-MM-yyyy')); 4 | 5 | INSERT INTO AUTHORITY (ID, NAME) VALUES (1, 'ROLE_USER'); 6 | INSERT INTO AUTHORITY (ID, NAME) VALUES (2, 'ROLE_ADMIN'); 7 | 8 | INSERT INTO USER_AUTHORITY (USER_ID, AUTHORITY_ID) VALUES (1, 1); 9 | INSERT INTO USER_AUTHORITY (USER_ID, AUTHORITY_ID) VALUES (1, 2); 10 | INSERT INTO USER_AUTHORITY (USER_ID, AUTHORITY_ID) VALUES (2, 1); 11 | INSERT INTO USER_AUTHORITY (USER_ID, AUTHORITY_ID) VALUES (3, 1); 12 | -------------------------------------------------------------------------------- /GatewayServerZuul/src/test/java/com/app/services/GatewayServerZuulApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.app.services; 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 GatewayServerZuulApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /HystrixDashboard/.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/ -------------------------------------------------------------------------------- /HystrixDashboard/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamtech/SpringBoot-Microservice-Eurka-Zuul/b232aed6c5ddd16913a934a80845c95d9d18067d/HystrixDashboard/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /HystrixDashboard/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /HystrixDashboard/README.md: -------------------------------------------------------------------------------- 1 | # Hystrix Dashboard Service : Enable one Dashboard screen related to the Circuit Breaker monitoring 2 | 3 | ### Hystrix Dashboard URL : 4 | http://localhost:8092/hystrix 5 | 6 | To monitor a single server use a URL such as: 7 | 8 | http://localhost:8005/actuator/hystrix.stream 9 | 10 | 11 | 12 | Use postman/browser and make a request to: 13 | 14 | http://localhost:8005/employees/ 15 | -------------------------------------------------------------------------------- /HystrixDashboard/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Migwn, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | echo $MAVEN_PROJECTBASEDIR 205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 206 | 207 | # For Cygwin, switch paths to Windows format before running java 208 | if $cygwin; then 209 | [ -n "$M2_HOME" ] && 210 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 211 | [ -n "$JAVA_HOME" ] && 212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 213 | [ -n "$CLASSPATH" ] && 214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 215 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 217 | fi 218 | 219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 220 | 221 | exec "$JAVACMD" \ 222 | $MAVEN_OPTS \ 223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 226 | -------------------------------------------------------------------------------- /HystrixDashboard/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 | -------------------------------------------------------------------------------- /HystrixDashboard/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | HystrixDashboard 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | HystrixDashboard 12 | Configuration Service For Employee Services 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.3.10.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | Hoxton.SR11 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-data-rest 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-starter-netflix-eureka-client 40 | 41 | 42 | org.springframework.cloud 43 | spring-cloud-starter-netflix-hystrix-dashboard 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-starter-test 49 | test 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-dependencies 58 | ${spring-cloud.version} 59 | pom 60 | import 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | org.springframework.boot 69 | spring-boot-maven-plugin 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /HystrixDashboard/src/main/java/com/app/services/HystrixDashboardApplication.java: -------------------------------------------------------------------------------- 1 | package com.app.services; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 6 | 7 | @EnableHystrixDashboard 8 | @SpringBootApplication 9 | public class HystrixDashboardApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(HystrixDashboardApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /HystrixDashboard/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: hystrix-dashboard 4 | 5 | 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://localhost:8761/eureka/ 10 | 11 | server: 12 | port: 8092 13 | 14 | #configure a list of hosts to allow connections to 15 | hystrix: 16 | dashboard: 17 | proxy-stream-allow-list: "*" 18 | -------------------------------------------------------------------------------- /HystrixDashboard/src/test/java/com/app/services/HystrixDashboardApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.app.services; 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 HystrixDashboardApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SpringBoot-Microservice with JWT and Role Based Access 2 | A Spring Boot Microservice Example that includes *Eureka Server, Zuul Gatway (JWT and RBA), Spring Cloud Config Server, Hystrix (Circuit Breaker) and three custom services for data.* 3 | 4 | **_A Front End Module for accessing these Microservices in written in Angular 6. Below is the link: 5 | [EmployeeApp Angular](https://github.com/iamtech/EmployeeApp)_** 6 | 7 | ## EurekaServerProj 8 | Hosts eureka server. 9 | PORT: 8761 10 | [EurekaServerProj Repo Link](https://github.com/iamtech/EurekaServerProj) 11 | 12 | ## GatewayServerZuul 13 | Gateway for microservies. It includes JWT and Rolebased Access. 14 | PORT: 8093 15 | [GatewayServerZuul Repo Link](https://github.com/iamtech/GatewayServerZuul) 16 | 17 | ## ConfigurationService 18 | Providing common configurations and constants to all microservices. 19 | PORT: 8094 20 | [ConfigurationService Repo Link](https://github.com/iamtech/ConfigurationService) 21 | 22 | ## HystrixDashboard 23 | Provides Hystrix Dashboard to monitor services with alternate methods in case of cuircuit break. 24 | PORT: 8092 25 | [HystrixDashboard Repo Link](https://github.com/iamtech/HystrixDashboardServer) 26 | 27 | ## EmployeeProducerService 28 | Custom Service that provides Employee Data. 29 | PORT: 8097 30 | [EmployeeProducerService Repo Link](https://github.com/iamtech/EmployeeProducerService) 31 | 32 | ## EmployeeAccessService 33 | Custom Service that calls EmployeeProducerService (testing purpose). 34 | PORT: 8099 35 | [EmployeeAccessService Repo Link](https://github.com/iamtech/EmployeeAccessService) 36 | 37 | ## EmployeeFeignClientService 38 | Service that calls EmployeeProducerService using OpenFeign (testing purpose). 39 | PORT: 8005 40 | [EmployeeFeignClientService Repo Link](https://github.com/iamtech/SpringBoot-Microservice-Eurka-Zuul/tree/master/EmployeeFeignClientService) 41 | 42 | ## TicketSystemService 43 | Custom Service that provides data on tickets/tasks. 44 | PORT: 8098 45 | [TicketSystemService Repo Link](https://github.com/iamtech/TicketSystemService) 46 | 47 | 48 | ### Credentials to test role based access from Zuul Gateway server 49 | *admin:admin 50 | user:userpass* 51 | -------------------------------------------------------------------------------- /TicketSystemService/.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/ -------------------------------------------------------------------------------- /TicketSystemService/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamtech/SpringBoot-Microservice-Eurka-Zuul/b232aed6c5ddd16913a934a80845c95d9d18067d/TicketSystemService/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /TicketSystemService/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /TicketSystemService/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | VOLUME /tmp 3 | ADD target/TicketSystemService-0.0.1-SNAPSHOT.jar TicketSystemService.jar 4 | RUN bash -c 'touch /TicketSystemService.jar' 5 | ENV JAVA_OPTS="" 6 | ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /TicketSystemService.jar"] -------------------------------------------------------------------------------- /TicketSystemService/README.md: -------------------------------------------------------------------------------- 1 | Service to generate continuous data for Realtime graph (in FrontEnd). 2 | -------------------------------------------------------------------------------- /TicketSystemService/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 | -------------------------------------------------------------------------------- /TicketSystemService/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | TicketSystemService 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | TicketSystemService 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.3.10.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | Hoxton.SR11 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-web 32 | 33 | 34 | org.springframework.cloud 35 | spring-cloud-starter-netflix-eureka-client 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter-actuator 47 | 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-starter-data-rest 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | org.springframework.cloud 60 | spring-cloud-dependencies 61 | ${spring-cloud.version} 62 | pom 63 | import 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.springframework.boot 72 | spring-boot-maven-plugin 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /TicketSystemService/src/main/java/com/app/service/TicketSystemServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.app.service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.context.annotation.ComponentScan; 7 | 8 | import com.app.service.controller.TicketSystemController; 9 | 10 | 11 | @EnableDiscoveryClient 12 | @SpringBootApplication 13 | @ComponentScan(basePackageClasses = TicketSystemController.class,basePackages="com.app.service") 14 | public class TicketSystemServiceApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(TicketSystemServiceApplication.class, args); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /TicketSystemService/src/main/java/com/app/service/bean/TicketSystemBean.java: -------------------------------------------------------------------------------- 1 | package com.app.service.bean; 2 | 3 | public class TicketSystemBean { 4 | 5 | public int ticketCount; 6 | public int ticketResolved; 7 | public int year; 8 | 9 | public TicketSystemBean(int ticketCount, int ticketResolved,int year) { 10 | super(); 11 | this.ticketCount = ticketCount; 12 | this.ticketResolved = ticketResolved; 13 | this.year = year; 14 | } 15 | 16 | public int getTicketCount() { 17 | return ticketCount; 18 | } 19 | public void setTicketCount(int ticketCount) { 20 | this.ticketCount = ticketCount; 21 | } 22 | public int getTicketResolved() { 23 | return ticketResolved; 24 | } 25 | public void setTicketResolved(int ticketResolved) { 26 | this.ticketResolved = ticketResolved; 27 | } 28 | 29 | public int getYear() { 30 | return year; 31 | } 32 | 33 | public void setYear(int year) { 34 | this.year = year; 35 | } 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /TicketSystemService/src/main/java/com/app/service/controller/TicketSystemController.java: -------------------------------------------------------------------------------- 1 | package com.app.service.controller; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.CrossOrigin; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | import com.app.service.dao.TicketSystemDoa; 11 | 12 | /* 13 | Commented as its been called from Zuul Gateway Service 14 | Uncomment if to call directly 15 | 16 | @CrossOrigin 17 | 18 | */ 19 | @RestController 20 | public class TicketSystemController { 21 | 22 | @Autowired 23 | TicketSystemDoa tcdao; 24 | 25 | @RequestMapping("/yeardata") 26 | public List all() { 27 | 28 | return tcdao.getTicktPerYear(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /TicketSystemService/src/main/java/com/app/service/dao/TicketSystemDoa.java: -------------------------------------------------------------------------------- 1 | package com.app.service.dao; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.stereotype.Repository; 7 | 8 | import com.app.service.bean.TicketSystemBean; 9 | 10 | @Repository 11 | public class TicketSystemDoa { 12 | 13 | public List getTicktStats(){ 14 | 15 | List tickList = new ArrayList<>(); 16 | TicketSystemBean tcb = new TicketSystemBean(2000, 788, 2014); 17 | tickList.add(tcb); 18 | tcb = new TicketSystemBean(1500, 875, 2015); 19 | tickList.add(tcb); 20 | tcb = new TicketSystemBean(1700, 1160, 2016); 21 | tickList.add(tcb); 22 | tcb = new TicketSystemBean(1200, 968, 2017); 23 | tickList.add(tcb); 24 | tcb = new TicketSystemBean(1000, 755, 2018); 25 | tickList.add(tcb); 26 | return tickList; 27 | } 28 | 29 | public List getTicktPerYear(){ 30 | List tickCount = new ArrayList<>(); 31 | tickCount.add(2000); 32 | tickCount.add(1500); 33 | tickCount.add(1700); 34 | tickCount.add(1200); 35 | tickCount.add(1000); 36 | return tickCount; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /TicketSystemService/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: ticket-microservice-dataset 4 | 5 | # Discovery Server Access 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://localhost:8761/eureka/ 10 | 11 | # HTTP Server (Tomcat) Port 12 | server: 13 | port: 8098 14 | 15 | management: 16 | endpoints: 17 | web: 18 | exposure: 19 | include: health,info,hystrix.stream 20 | 21 | -------------------------------------------------------------------------------- /TicketSystemService/src/test/java/com/app/service/TicketSystemServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.app.service; 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 TicketSystemServiceApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /employee-microservice-client-development.properties: -------------------------------------------------------------------------------- 1 | msg = Hello - this is from config server - Development Environment 2 | -------------------------------------------------------------------------------- /employee-microservice-client-production.properties: -------------------------------------------------------------------------------- 1 | msg = Hello world - this is from config server – Production environment 2 | -------------------------------------------------------------------------------- /employee-microservice-client.properties: -------------------------------------------------------------------------------- 1 | msg = Hello - this is from config server 2 | --------------------------------------------------------------------------------