├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── programandoointentandolo │ │ └── tsb │ │ ├── TutorialSpringBootApplication.java │ │ ├── config │ │ ├── ConfiguracionMensajes.java │ │ └── ConfiguracionValidador.java │ │ ├── controller │ │ ├── InicioController.java │ │ └── ProductoController.java │ │ ├── entity │ │ └── Producto.java │ │ ├── repository │ │ └── ProductoRepository.java │ │ ├── service │ │ ├── ProductoService.java │ │ └── ProductoServiceImpl.java │ │ └── validator │ │ ├── ProductoCodigo.java │ │ ├── ProductoCodigoValidator.java │ │ ├── ProductoPrecioUnidadesMinimo.java │ │ ├── ProductoPrecioUnidadesMinimoValidator.java │ │ └── grupos │ │ ├── Crear.java │ │ └── Editar.java └── resources │ ├── application.yml │ ├── i18n │ ├── messages.properties │ ├── messages_en.properties │ └── messages_es_MX.properties │ ├── static │ ├── css │ │ ├── estilos.css │ │ ├── tema_dark.css │ │ └── tema_light.css │ └── img │ │ ├── idiomas │ │ ├── mexico.svg │ │ ├── spain.svg │ │ └── usa.svg │ │ └── logo.png │ └── templates │ ├── formulario.html │ ├── layouts │ └── base.html │ └── lista.html └── test └── java └── com └── programandoointentandolo └── tsb └── TutorialSpringBootApplicationTests.java /.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/ -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isalasc/tutorial-spring-boot/6e46ac1c8a7d9b9bbb521574650dae5213b4288f/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tutorial de Spring Boot 2 | 3 | 4 | 5 | 1. Arrancando con Spring Boot: 6 | [Ver post](https://programandoointentandolo.com/2018/10/tutorial-spring-boot-creando-nuestra-primera-aplicacion.html) 7 | 8 | 2. Spring MVC con Spring Boot + Thymeleaf: 9 | [Ver post](https://programandoointentandolo.com/2018/12/spring-mvc-con-spring-boot-thymeleaf.html) 10 | 11 | 3. Fragmets Thymeleaf 12 | [Ver post](https://programandoointentandolo.com/2019/02/thymeleaf-fragmets.html) 13 | 14 | 4. Validación de formularios: 15 | [Ver post](https://programandoointentandolo.com/2019/03/spring-boot-validacion-spring-mvc-y-thymeleaf.html) 16 | 17 | 5. Validadores personalizados: 18 | [Ver post](https://programandoointentandolo.com/2019/03/crear-un-validador-personalizado-en-spring.html) 19 | 20 | 6. Spring MVC Validation Groups: 21 | [Ver post](https://programandoointentandolo.com/2019/04/spring-mvc-validation-groups.html) 22 | 23 | 7. Spring Boot: Internacionalización (i18n): 24 | [Ver post](https://programandoointentandolo.com/2019/06/spring-boot-internacionalizacion-i18n.html) 25 | 26 | 8. Perfiles Maven y Spring Boot: 27 | [Ver post](https://programandoointentandolo.com/2019/07/spring-boot-profiles.html) 28 | 29 | 9. Como desplegar una aplicación Spring Boot + Angular en un servidor cloud VPS: 30 | [Ver post](https://programandoointentandolo.com/2019/07/como-desplegar-aplicacion-spring-boot-angular-servidor-cloud-vps.html) 31 | 32 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | 8 | dev 9 | 10 | dev 11 | 12 | 13 | true 14 | 15 | 16 | 17 | prod 18 | 19 | prod 20 | 21 | 22 | 23 | 24 | com.programandoointentandolo.tsb 25 | tutorial-spring-boot 26 | 0.0.1-SNAPSHOT 27 | jar 28 | 29 | tutorial-spring-boot 30 | Tutorial de Spring Boot 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-parent 35 | 2.0.4.RELEASE 36 | 37 | 38 | 39 | 40 | UTF-8 41 | UTF-8 42 | 8 43 | 44 | 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-data-jpa 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter-thymeleaf 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-starter-web 58 | 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-devtools 63 | runtime 64 | 65 | 66 | mysql 67 | mysql-connector-java 68 | runtime 69 | 70 | 71 | org.springframework.boot 72 | spring-boot-starter-test 73 | test 74 | 75 | 76 | javax.xml.bind 77 | jaxb-api 78 | 2.3.0 79 | 80 | 81 | 82 | 83 | 84 | 85 | org.springframework.boot 86 | spring-boot-maven-plugin 87 | 88 | true 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/TutorialSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class TutorialSpringBootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(TutorialSpringBootApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/config/ConfiguracionMensajes.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.config; 2 | 3 | import java.util.Locale; 4 | 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.servlet.LocaleResolver; 8 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 9 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 10 | import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; 11 | import org.springframework.web.servlet.i18n.SessionLocaleResolver; 12 | 13 | @Configuration 14 | public class ConfiguracionMensajes implements WebMvcConfigurer { 15 | 16 | // Alternativa a la declaracion en el application.yml 17 | // @Bean 18 | // public MessageSource messageSource() { 19 | // ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); 20 | // messageSource.setBasename("classpath:i18n/messages"); 21 | // messageSource.setDefaultEncoding("UTF-8"); 22 | // return messageSource; 23 | // } 24 | 25 | @Bean 26 | public LocaleResolver localeResolver() { 27 | SessionLocaleResolver localeResolver = new SessionLocaleResolver(); 28 | localeResolver.setDefaultLocale(Locale.getDefault()); 29 | return localeResolver; 30 | } 31 | 32 | @Bean 33 | public LocaleChangeInterceptor localeChangeInterceptor() { 34 | LocaleChangeInterceptor localeInterceptor = new LocaleChangeInterceptor(); 35 | localeInterceptor.setIgnoreInvalidLocale(true); 36 | localeInterceptor.setParamName("idioma"); 37 | return localeInterceptor; 38 | } 39 | 40 | @Override 41 | public void addInterceptors(InterceptorRegistry registry) { 42 | registry.addInterceptor(localeChangeInterceptor()); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/config/ConfiguracionValidador.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.MessageSource; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; 8 | 9 | @Configuration 10 | public class ConfiguracionValidador { 11 | 12 | @Autowired 13 | MessageSource messageSource; 14 | 15 | @Bean 16 | public LocalValidatorFactoryBean getValidator() { 17 | LocalValidatorFactoryBean validatorFactory = new LocalValidatorFactoryBean(); 18 | validatorFactory.setValidationMessageSource(messageSource); 19 | return validatorFactory; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/controller/InicioController.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | 6 | @Controller 7 | public class InicioController { 8 | 9 | @GetMapping("/") 10 | public String inicio() { 11 | return "redirect:/productos/lista"; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/controller/ProductoController.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.controller; 2 | 3 | import java.util.Map; 4 | 5 | import javax.validation.groups.Default; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.MessageSource; 9 | import org.springframework.context.i18n.LocaleContextHolder; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.ui.Model; 12 | import org.springframework.ui.ModelMap; 13 | import org.springframework.validation.BindingResult; 14 | import org.springframework.validation.annotation.Validated; 15 | import org.springframework.web.bind.annotation.GetMapping; 16 | import org.springframework.web.bind.annotation.PathVariable; 17 | import org.springframework.web.bind.annotation.PostMapping; 18 | import org.springframework.web.bind.annotation.RequestMapping; 19 | import org.springframework.web.servlet.ModelAndView; 20 | 21 | import com.programandoointentandolo.tsb.entity.Producto; 22 | import com.programandoointentandolo.tsb.service.ProductoService; 23 | import com.programandoointentandolo.tsb.validator.grupos.Crear; 24 | import com.programandoointentandolo.tsb.validator.grupos.Editar; 25 | 26 | @Controller 27 | @RequestMapping("productos") 28 | public class ProductoController { 29 | 30 | public static final String VISTA_LISTA = "lista"; 31 | public static final String VISTA_FORMULARIO = "formulario"; 32 | 33 | @Autowired 34 | private ProductoService productoService; 35 | 36 | @Autowired 37 | private MessageSource mensajes; 38 | 39 | @GetMapping(value = "/lista") 40 | public String listar(Model model) { 41 | model.addAttribute("titulo", mensajes.getMessage("aplicacion.nombre", null, LocaleContextHolder.getLocale())); 42 | model.addAttribute("productos", productoService.obtenerTodosProductos()); 43 | 44 | return VISTA_LISTA; 45 | } 46 | 47 | @GetMapping(value = "/listaModelMap") 48 | public String listarModelMap(ModelMap model) { 49 | model.addAttribute("titulo", mensajes.getMessage("aplicacion.nombre", null, LocaleContextHolder.getLocale())); 50 | model.addAttribute("productos", productoService.obtenerTodosProductos()); 51 | 52 | return VISTA_LISTA; 53 | } 54 | 55 | @GetMapping("/listaModelAndView") 56 | public ModelAndView listarModelAndView() { 57 | ModelAndView mav = new ModelAndView(); 58 | mav.addObject("titulo", mensajes.getMessage("aplicacion.nombre", null, LocaleContextHolder.getLocale())); 59 | mav.addObject("productos", productoService.obtenerTodosProductos()); 60 | mav.setViewName(VISTA_LISTA); 61 | 62 | return mav; 63 | } 64 | 65 | @GetMapping("/crear") 66 | public String crear(Map model) { 67 | Producto producto = new Producto(); 68 | model.put("producto", producto); 69 | model.put("titulo", mensajes.getMessage("aplicacion.nombre", null, LocaleContextHolder.getLocale())); 70 | model.put("accion", "guardar"); 71 | 72 | return VISTA_FORMULARIO; 73 | } 74 | 75 | @GetMapping("/editar/{id}") 76 | public String editar(@PathVariable(value = "id") Integer id, Map model) { 77 | Producto producto = productoService.obtenerProducto(id).orElse(null); 78 | model.put("producto", producto); 79 | model.put("titulo", mensajes.getMessage("aplicacion.nombre", null, LocaleContextHolder.getLocale())); 80 | model.put("accion", "../actualizar"); 81 | 82 | return producto != null ? VISTA_FORMULARIO : "redirect:../" + VISTA_LISTA; 83 | } 84 | 85 | @PostMapping("/guardar") 86 | public String guardar(@Validated({ Crear.class, Default.class }) Producto producto, BindingResult result) { 87 | if (result.hasErrors()) { 88 | return VISTA_FORMULARIO; 89 | } 90 | 91 | productoService.guardar(producto); 92 | 93 | return "redirect:" + VISTA_LISTA; 94 | } 95 | 96 | @PostMapping("/actualizar") 97 | public String actualizar(@Validated({ Editar.class, Default.class }) Producto producto, BindingResult result) { 98 | if (result.hasErrors()) { 99 | return VISTA_FORMULARIO; 100 | } 101 | 102 | productoService.guardar(producto); 103 | 104 | return "redirect:" + VISTA_LISTA; 105 | } 106 | 107 | @GetMapping("/eliminar/{id}") 108 | public String eliminar(@PathVariable(value = "id") Integer idProducto) { 109 | productoService.eliminar(idProducto); 110 | 111 | return "redirect:../" + VISTA_LISTA; 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/entity/Producto.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.entity; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.GeneratedValue; 5 | import javax.persistence.GenerationType; 6 | import javax.persistence.Id; 7 | import javax.validation.constraints.Max; 8 | import javax.validation.constraints.Min; 9 | import javax.validation.constraints.NotEmpty; 10 | import javax.validation.constraints.NotNull; 11 | import javax.validation.constraints.Null; 12 | import javax.validation.constraints.Pattern; 13 | import javax.validation.constraints.Size; 14 | 15 | import com.programandoointentandolo.tsb.validator.ProductoCodigo; 16 | import com.programandoointentandolo.tsb.validator.ProductoPrecioUnidadesMinimo; 17 | import com.programandoointentandolo.tsb.validator.grupos.Crear; 18 | import com.programandoointentandolo.tsb.validator.grupos.Editar; 19 | 20 | @ProductoPrecioUnidadesMinimo 21 | @Entity 22 | public class Producto { 23 | 24 | @Id 25 | @Null(groups = Crear.class) 26 | @NotNull(groups = Editar.class) 27 | @GeneratedValue(strategy = GenerationType.IDENTITY) 28 | private Integer id; 29 | 30 | @ProductoCodigo 31 | @Size(min = 3, max = 8) 32 | @Pattern(regexp = "[A-Z0-9]+") 33 | private String codigo; 34 | 35 | @NotEmpty 36 | private String nombre; 37 | 38 | @NotNull 39 | @Min(value = 2, groups = {Crear.class, Editar.class}) 40 | @Max(100) 41 | private Double precio; 42 | 43 | @NotNull 44 | @Min(1) 45 | private Integer unidadesMinimas; 46 | 47 | public Producto() { 48 | 49 | } 50 | 51 | public Integer getId() { 52 | return id; 53 | } 54 | 55 | public void setId(Integer id) { 56 | this.id = id; 57 | } 58 | 59 | public String getNombre() { 60 | return nombre; 61 | } 62 | 63 | public void setNombre(String nombre) { 64 | this.nombre = nombre; 65 | } 66 | 67 | public Double getPrecio() { 68 | return precio; 69 | } 70 | 71 | public void setPrecio(Double precio) { 72 | this.precio = precio; 73 | } 74 | 75 | public String getCodigo() { 76 | return codigo; 77 | } 78 | 79 | public void setCodigo(String codigo) { 80 | this.codigo = codigo; 81 | } 82 | 83 | public Integer getUnidadesMinimas() { 84 | return unidadesMinimas; 85 | } 86 | 87 | public void setUnidadesMinimas(Integer unidadesMinimas) { 88 | this.unidadesMinimas = unidadesMinimas; 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/repository/ProductoRepository.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import com.programandoointentandolo.tsb.entity.Producto; 7 | 8 | @Repository 9 | public interface ProductoRepository extends JpaRepository { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/service/ProductoService.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.service; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | import com.programandoointentandolo.tsb.entity.Producto; 7 | 8 | public interface ProductoService { 9 | 10 | /** 11 | * Guarda el producto 12 | * 13 | * @param producto 14 | */ 15 | void guardar(Producto producto); 16 | 17 | /** 18 | * Recupera la lista completa de productos 19 | * 20 | * @return 21 | */ 22 | List obtenerTodosProductos(); 23 | 24 | /** 25 | * Devuelve el producto correspondiente al id si existe 26 | * 27 | * @param id Id del producto 28 | * @return 29 | */ 30 | Optional obtenerProducto(Integer id); 31 | 32 | /** 33 | * Elimina el producto correspondiente al id 34 | * 35 | * @param id Id del producto 36 | */ 37 | void eliminar(Integer id); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/service/ProductoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.service; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.programandoointentandolo.tsb.entity.Producto; 10 | import com.programandoointentandolo.tsb.repository.ProductoRepository; 11 | 12 | @Service 13 | public class ProductoServiceImpl implements ProductoService { 14 | 15 | @Autowired 16 | private ProductoRepository productoRepository; 17 | 18 | @Override 19 | public void guardar(Producto producto) { 20 | productoRepository.save(producto); 21 | } 22 | 23 | @Override 24 | public List obtenerTodosProductos() { 25 | return productoRepository.findAll(); 26 | } 27 | 28 | @Override 29 | public Optional obtenerProducto(Integer id) { 30 | return productoRepository.findById(id); 31 | } 32 | 33 | @Override 34 | public void eliminar(Integer id) { 35 | productoRepository.deleteById(id); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/validator/ProductoCodigo.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.validator; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | 12 | /** 13 | * Comprueba que la suma de los caracteres del codigo este dentro del rango valido 14 | */ 15 | @Documented 16 | @Constraint(validatedBy = ProductoCodigoValidator.class) 17 | @Target({ ElementType.METHOD, ElementType.FIELD }) 18 | @Retention(RetentionPolicy.RUNTIME) 19 | public @interface ProductoCodigo { 20 | String message() default "{productoCodigoValido.mensajePorDefecto}"; 21 | 22 | Class[] groups() default {}; 23 | 24 | Class[] payload() default {}; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/validator/ProductoCodigoValidator.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.validator; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | 6 | public class ProductoCodigoValidator implements ConstraintValidator { 7 | 8 | private static final int MAX = 500; 9 | private static final int MIN = 250; 10 | 11 | @Override 12 | public boolean isValid(String codigo, ConstraintValidatorContext context) { 13 | int suma = codigo.chars().sum(); 14 | 15 | return suma > MIN && suma < MAX; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/validator/ProductoPrecioUnidadesMinimo.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.validator; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | 12 | /** 13 | * Comprueba que el precio total para el numero minimo de unidades sea mayor de 10 14 | */ 15 | @Documented 16 | @Constraint(validatedBy = ProductoPrecioUnidadesMinimoValidator.class) 17 | @Target({ ElementType.TYPE }) 18 | @Retention(RetentionPolicy.RUNTIME) 19 | public @interface ProductoPrecioUnidadesMinimo { 20 | String message() default "{productoPrecioUnidadesMinimo.mensajePorDefecto}"; 21 | 22 | Class[] groups() default {}; 23 | 24 | Class[] payload() default {}; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/validator/ProductoPrecioUnidadesMinimoValidator.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.validator; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | 6 | import com.programandoointentandolo.tsb.entity.Producto; 7 | 8 | public class ProductoPrecioUnidadesMinimoValidator 9 | implements ConstraintValidator { 10 | 11 | @Override 12 | public boolean isValid(Producto producto, ConstraintValidatorContext context) { 13 | if (producto.getPrecio() == null || producto.getUnidadesMinimas() == null) { 14 | return false; 15 | } 16 | 17 | return producto.getPrecio() * producto.getUnidadesMinimas() > 10; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/validator/grupos/Crear.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.validator.grupos; 2 | 3 | public interface Crear { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/programandoointentandolo/tsb/validator/grupos/Editar.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb.validator.grupos; 2 | 3 | public interface Editar { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9876 3 | servlet: 4 | context-path: /miapp 5 | 6 | spring: 7 | profiles: 8 | active: '@appProfile@' 9 | datasource: 10 | driver-class-name: com.mysql.jdbc.Driver 11 | jpa: 12 | database-platform: org.hibernate.dialect.MySQL57Dialect 13 | hibernate: 14 | ddl-auto: create-drop 15 | messages: 16 | basename: i18n/messages 17 | encoding: UTF-8 18 | 19 | logging: 20 | level: 21 | org: 22 | hibernate: 23 | SQL: debug 24 | 25 | --- 26 | 27 | spring: 28 | profiles: dev 29 | datasource: 30 | url: jdbc:mysql://localhost:8889/pruebas?useSSL=false 31 | username: root 32 | password: root 33 | 34 | --- 35 | 36 | spring: 37 | profiles: prod 38 | datasource: 39 | url: jdbc:mysql://10.20.30.40:3306/pruebas 40 | username: user 41 | password: Mipassword1+ 42 | -------------------------------------------------------------------------------- /src/main/resources/i18n/messages.properties: -------------------------------------------------------------------------------- 1 | aplicacion.nombre: Tutorial Spring Boot 2 | 3 | # Menu 4 | menu.productos = Productos 5 | buscador.boton = Buscar 6 | buscador.placeholder = Buscar... 7 | 8 | # Productos 9 | productos.lista.titulo = Lista de productos 10 | productos.formulario.titulo.nuevo = Nuevo producto 11 | productos.formulario.titulo.editar = Editar producto 12 | 13 | productos.producto.id = Id 14 | productos.producto.codigo = Código 15 | productos.producto.nombre = Nombre 16 | productos.producto.precio = Precio 17 | productos.producto.unidadesMinimas = Unidades mínimas 18 | 19 | productos.acciones.editar = Editar 20 | productos.acciones.eliminar = Eliminar 21 | productos.acciones.anadir = Añadir Producto 22 | productos.acciones.guardar = Guardar 23 | productos.acciones.cancelar = Cancelar 24 | 25 | # Validadores producto 26 | Size.producto.codigo = El código del producto tiene que tener entre {2} y {1} caracteres 27 | Pattern.producto.codigo = El código del producto solo puede tener letras mayúsculas o números 28 | NotEmpty.producto.nombre = El nombre del producto es obligatorio 29 | NotNull.producto.precio = El precio es obligatorio 30 | Min.producto.precio = El precio mínimo es {1} 31 | Max.producto.precio = El precio máximo es {1} 32 | NotNull.producto.unidadesMinimas = El mínimo es una unidad 33 | Min.producto.unidadesMinimas = El mínimo es {1} unidad 34 | 35 | # Validadores personalizados 36 | productoCodigoValido.mensajePorDefecto = Código no valido 37 | productoPrecioUnidadesMinimo.mensajePorDefecto = El precio total para el número mínimo de unidades tiene que ser mayor que 10 38 | -------------------------------------------------------------------------------- /src/main/resources/i18n/messages_en.properties: -------------------------------------------------------------------------------- 1 | aplicacion.nombre: Spring Boot Tutorial 2 | 3 | # Menu 4 | menu.productos = Products 5 | buscador.boton = Search 6 | buscador.placeholder = Search... 7 | 8 | # Productos 9 | productos.lista.titulo = Products list 10 | productos.formulario.titulo.nuevo = New product 11 | productos.formulario.titulo.editar = Edit product 12 | 13 | productos.producto.id = Id 14 | productos.producto.codigo = Code 15 | productos.producto.nombre = Name 16 | productos.producto.precio = Price 17 | productos.producto.unidadesMinimas = Minimum Amount 18 | 19 | productos.acciones.editar = Edit 20 | productos.acciones.eliminar = Delete 21 | productos.acciones.anadir = Add Product 22 | productos.acciones.guardar = Save 23 | productos.acciones.cancelar = Cancel 24 | 25 | # Validadores producto 26 | Size.producto.codigo = The product code must have between {2} and {1} characters 27 | Pattern.producto.codigo = The product code can only have uppercase letters or numbers 28 | NotEmpty.producto.nombre = Product name is required 29 | NotNull.producto.precio = Price is required 30 | Min.producto.precio = The minimum price is {1} 31 | Max.producto.precio = The maximum price is {1} 32 | NotNull.producto.unidadesMinimas = The number of units is mandatory 33 | Min.producto.unidadesMinimas = The minimum is {1} unit 34 | 35 | # Validadores personalizados 36 | productoCodigoValido.mensajePorDefecto = Code not valid 37 | productoPrecioUnidadesMinimo.mensajePorDefecto = The total price for the minimum number of units must be greater than 10 38 | -------------------------------------------------------------------------------- /src/main/resources/i18n/messages_es_MX.properties: -------------------------------------------------------------------------------- 1 | aplicacion.nombre: Tutorial Spring Boot 2 | 3 | # Menu 4 | menu.productos = Productos 5 | buscador.boton = Buscar 6 | buscador.placeholder = Buscar... 7 | 8 | # Productos 9 | productos.lista.titulo = Lista de productos 10 | productos.formulario.titulo.nuevo = Nuevo producto 11 | productos.formulario.titulo.editar = Editar producto 12 | 13 | productos.producto.id = Id 14 | productos.producto.codigo = Código 15 | productos.producto.nombre = Nombre 16 | productos.producto.precio = Precio 17 | productos.producto.unidadesMinimas = Unidades mínimas 18 | 19 | productos.acciones.editar = Editar 20 | productos.acciones.eliminar = Eliminar 21 | productos.acciones.anadir = Agregar Producto 22 | productos.acciones.guardar = Guardar 23 | productos.acciones.cancelar = Cancelar 24 | 25 | # Validadores producto 26 | Size.producto.codigo = El código del producto tiene que tener entre {2} y {1} caracteres 27 | Pattern.producto.codigo = El código del producto solo puede tener letras mayúsculas o números 28 | NotEmpty.producto.nombre = El nombre del producto es obligatorio 29 | NotNull.producto.precio = El precio es obligatorio 30 | Min.producto.precio = El precio mínimo es {1} 31 | Max.producto.precio = El precio máximo es {1} 32 | NotNull.producto.unidadesMinimas = El mínimo es una unidad 33 | Min.producto.unidadesMinimas = El mínimo es {1} unidad 34 | 35 | # Validadores personalizados 36 | productoCodigoValido.mensajePorDefecto = Código no valido 37 | productoPrecioUnidadesMinimo.mensajePorDefecto = El precio total para el número mínimo de unidades tiene que ser mayor que 10 38 | -------------------------------------------------------------------------------- /src/main/resources/static/css/estilos.css: -------------------------------------------------------------------------------- 1 | 2 | .container { 3 | margin-top: 20px; 4 | } 5 | 6 | footer { 7 | position: fixed; 8 | bottom: 0; 9 | margin: auto; 10 | padding: 20px; 11 | width: 100%; 12 | text-align: center; 13 | } 14 | 15 | footer .info-copyrigth { 16 | display: inline-block; 17 | } 18 | 19 | 20 | header .idiomas { 21 | padding: 0 10px; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resources/static/css/tema_dark.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #454b51; 3 | color: #fff; 4 | } 5 | 6 | .container { 7 | margin-top: 20px; 8 | } 9 | 10 | footer { 11 | position: fixed; 12 | bottom: 0; 13 | margin: auto; 14 | padding: 20px; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | 19 | footer .info-copyrigth { 20 | display: inline-block; 21 | color: #fff; 22 | } 23 | 24 | footer .info-copyrigth a { 25 | color: #fff; 26 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/tema_light.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #e8e9ea; 3 | color: #000; 4 | } 5 | 6 | footer .info-copyrigth { 7 | color: #000; 8 | } 9 | 10 | footer .info-copyrigth a { 11 | color: #000; 12 | } -------------------------------------------------------------------------------- /src/main/resources/static/img/idiomas/mexico.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 15 | 16 | 18 | 19 | 26 | 28 | 29 | 32 | 34 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/main/resources/static/img/idiomas/spain.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 20 | 21 | 22 | 24 | 25 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 50 | 53 | 56 | 59 | 60 | 63 | 65 | 66 | 67 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /src/main/resources/static/img/idiomas/usa.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 24 | 25 | 26 | 27 | 28 | 31 | 34 | 37 | 40 | 43 | 46 | 49 | 52 | 55 | 58 | 61 | 64 | 67 | 70 | 73 | 76 | 79 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 106 | 109 | 112 | 115 | 118 | 121 | 124 | 127 | 130 | 133 | 136 | 139 | 142 | 145 | 148 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /src/main/resources/static/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isalasc/tutorial-spring-boot/6e46ac1c8a7d9b9bbb521574650dae5213b4288f/src/main/resources/static/img/logo.png -------------------------------------------------------------------------------- /src/main/resources/templates/formulario.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 |
10 |
11 |
12 |

13 |
14 |
15 | 16 | 17 | 24 | 25 |
26 | 27 | 28 |
29 | 30 |
31 | 32 | 33 |
34 |
35 |
36 | 37 |
38 | 39 | 40 |
41 |
42 |
43 | 44 |
45 | 46 | 47 |
48 |
49 |
50 | 51 |
52 | 53 | 54 | 55 |
56 |
57 |
58 |
59 | 60 | 61 |
62 |
63 |
64 |
65 |
66 |
67 | 68 |
69 | 70 | -------------------------------------------------------------------------------- /src/main/resources/templates/layouts/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 46 |
47 | 48 | 49 |
50 |
51 | 52 | 53 | 57 | 58 | -------------------------------------------------------------------------------- /src/main/resources/templates/lista.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 |
10 |
11 |
12 |

13 |
14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 42 | 43 | 44 |
32 | 33 | 34 |
40 | 41 |
45 |
46 |
47 |
48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/test/java/com/programandoointentandolo/tsb/TutorialSpringBootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.programandoointentandolo.tsb; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | @RunWith(SpringRunner.class) 11 | @SpringBootTest 12 | public class TutorialSpringBootApplicationTests { 13 | 14 | @Test 15 | public void contextLoads() { 16 | } 17 | 18 | } 19 | --------------------------------------------------------------------------------