diff --git a/HELP.md b/HELP.md new file mode 100644 index 0000000..cdac652 --- /dev/null +++ b/HELP.md @@ -0,0 +1,23 @@ +# Getting Started + +### Reference Documentation +For further reference, please consider the following sections: + +* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) +* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.2.2/maven-plugin/reference/html/) +* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.2.2/maven-plugin/reference/html/#build-image) +* [Spring Boot DevTools](https://docs.spring.io/spring-boot/docs/3.2.2/reference/htmlsingle/index.html#using.devtools) +* [Spring Data JPA](https://docs.spring.io/spring-boot/docs/3.2.2/reference/htmlsingle/index.html#data.sql.jpa-and-spring-data) +* [Thymeleaf](https://docs.spring.io/spring-boot/docs/3.2.2/reference/htmlsingle/index.html#web.servlet.spring-mvc.template-engines) +* [Spring Web](https://docs.spring.io/spring-boot/docs/3.2.2/reference/htmlsingle/index.html#web) + +### Guides +The following guides illustrate how to use some features concretely: + +* [Accessing data with MySQL](https://spring.io/guides/gs/accessing-data-mysql/) +* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/) +* [Handling Form Submission](https://spring.io/guides/gs/handling-form-submission/) +* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) +* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) +* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/) + diff --git a/README.md b/README.md index 459567a..a5bcbd5 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ -# crud-spring-boot-thymeleaf \ No newline at end of file +# crud-spring-boot-thymeleaf + +## Teachnologies used +1. spring-boot +2. spring-data-jpa +3. spring-web-mvc +4. thymeleaf diff --git a/mvnw b/mvnw new file mode 100755 index 0000000..66df285 --- /dev/null +++ b/mvnw @@ -0,0 +1,308 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.2.0 +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "$(uname)" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=$(java-config --jre-home) + fi +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --unix "$CLASSPATH") +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && + JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=$(which readlink) + if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then + if $darwin ; then + javaHome="$(dirname "\"$javaExecutable\"")" + javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" + else + javaExecutable="$(readlink -f "\"$javaExecutable\"")" + fi + javaHome="$(dirname "\"$javaExecutable\"")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=$(cd "$wdir/.." || exit 1; pwd) + fi + # end of workaround + done + printf '%s' "$(cd "$basedir" || exit 1; pwd)" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + # Remove \r in case we run on Windows within Git Bash + # and check out the repository with auto CRLF management + # enabled. Otherwise, we may read lines that are delimited with + # \r\n and produce $'-Xarg\r' rather than -Xarg due to word + # splitting rules. + tr -s '\r\n' ' ' < "$1" + fi +} + +log() { + if [ "$MVNW_VERBOSE" = true ]; then + printf '%s\n' "$1" + fi +} + +BASE_DIR=$(find_maven_basedir "$(dirname "$0")") +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR +log "$MAVEN_PROJECTBASEDIR" + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" +if [ -r "$wrapperJarPath" ]; then + log "Found $wrapperJarPath" +else + log "Couldn't find $wrapperJarPath, downloading it ..." + + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + fi + while IFS="=" read -r key value; do + # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) + safeValue=$(echo "$value" | tr -d '\r') + case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; + esac + done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" + log "Downloading from: $wrapperUrl" + + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget > /dev/null; then + log "Found wget ... using wget" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + log "Found curl ... using curl" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + else + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + fi + else + log "Falling back to using Java to download" + javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaSource=$(cygpath --path --windows "$javaSource") + javaClass=$(cygpath --path --windows "$javaClass") + fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + log " - Compiling MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/javac" "$javaSource") + fi + if [ -e "$javaClass" ]; then + log " - Running MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +# If specified, validate the SHA-256 sum of the Maven wrapper jar file +wrapperSha256Sum="" +while IFS="=" read -r key value; do + case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; + esac +done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +if [ -n "$wrapperSha256Sum" ]; then + wrapperSha256Result=false + if command -v sha256sum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + elif command -v shasum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." + echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." + exit 1 + fi + if [ $wrapperSha256Result = false ]; then + echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 + echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 + echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 + exit 1 + fi +fi + +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +# shellcheck disable=SC2086 # safe args +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..95ba6f5 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,205 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.2.0 +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %WRAPPER_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file +SET WRAPPER_SHA_256_SUM="" +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B +) +IF NOT %WRAPPER_SHA_256_SUM%=="" ( + powershell -Command "&{"^ + "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ + "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ + " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ + " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ + " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ + " exit 1;"^ + "}"^ + "}" + if ERRORLEVEL 1 goto error +) + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..c91e4b3 --- /dev/null +++ b/pom.xml @@ -0,0 +1,69 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.2.2 + + + com.runner + crud-spring-boot-thymeleaf + 0.0.1-SNAPSHOT + war + crud-spring-boot-thymeleaf + crud-application using spring boot + + 21 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.mysql + mysql-connector-j + runtime + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/src/main/java/com/crudapp/ServletInitializer.java b/src/main/java/com/crudapp/ServletInitializer.java new file mode 100644 index 0000000..c017ccf --- /dev/null +++ b/src/main/java/com/crudapp/ServletInitializer.java @@ -0,0 +1,13 @@ +package com.crudapp; + +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +public class ServletInitializer extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(SpringBootCrudApplication.class); + } + +} diff --git a/src/main/java/com/crudapp/SpringBootCrudApplication.java b/src/main/java/com/crudapp/SpringBootCrudApplication.java new file mode 100644 index 0000000..83b708c --- /dev/null +++ b/src/main/java/com/crudapp/SpringBootCrudApplication.java @@ -0,0 +1,27 @@ +package com.crudapp; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; + +@SpringBootApplication(exclude={SecurityAutoConfiguration.class}) +public class SpringBootCrudApplication implements CommandLineRunner{ + + private static Logger LOGGER = LoggerFactory.getLogger(SpringBootCrudApplication.class); + + public static void main(String[] args) { + SpringApplication.run(SpringBootCrudApplication.class, args); + + LOGGER.info("-- APPLICATION RUNNING --"); + } + + @Override + public void run(String... args) throws Exception { + + + } + +} diff --git a/src/main/java/com/crudapp/controller/UserController.java b/src/main/java/com/crudapp/controller/UserController.java new file mode 100644 index 0000000..c953224 --- /dev/null +++ b/src/main/java/com/crudapp/controller/UserController.java @@ -0,0 +1,155 @@ +package com.crudapp.controller; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.sql.Date; + +import org.springframework.core.io.Resource; +import org.springframework.core.io.UrlResource; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.MediaTypeFactory; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.crudapp.entity.User; +import com.crudapp.service.UserService; + +@Controller("/") +public class UserController { + + private UserService userService; + private String UPLOAD_DIR = System.getProperty("user.dir") + "/src/main/resources/static/uploads/"; + + public UserController(UserService userService) { + super(); + this.userService = userService; + } + + @GetMapping("/") + public String getUsersList(@RequestParam(defaultValue="1") Integer pageNo, + @RequestParam(defaultValue="5") Integer pageSize, + + Model model) { + model.addAttribute("users", userService.getUsersByPagination(pageNo, pageSize)); + model.addAttribute("totalPages",((int)(userService.getUsersCount()/pageSize)) + 1); + model.addAttribute("currentPage", pageNo); + + return "users"; + } + + @GetMapping("/new") + public String createNewUser(Model model) { + User user = new User(); + model.addAttribute("user", user); + return "create-new-user"; + } + + @PostMapping("/users") + public String saveUser(@RequestParam("name") String name, + @RequestParam("dob") Date dob, + @RequestParam("email") String email, + @RequestParam("password") String password, + @RequestParam("image") MultipartFile image, + RedirectAttributes redirectAttributes, + Model model + ) throws IOException { + + String encryptedPassword = userService.encryptPassword(password); + String uploadedImage = userService.uploadImage(image); + + User user = new User(name, dob, email, encryptedPassword, uploadedImage); + userService.saveUser(user); + + redirectAttributes.addFlashAttribute("flashMessage", "User created successfully!"); + return "redirect:/"; + + } + + @GetMapping("/update/{id}") + public String updateUser(@PathVariable("id") Long id, Model model) { + model.addAttribute("user", userService.getUserById(id)); + return "update-user"; + } + + @PostMapping("/users/{id}") + public String saveUpdatedUser( + @PathVariable("id") Long id, + @RequestParam("name") String name, + @RequestParam("dob") Date dob, + @RequestParam("email") String email, + @RequestParam("password") String password, + @RequestParam("image") MultipartFile image, + @RequestParam("oldImage") String oldImageName, + Model model, + RedirectAttributes redirectAttributes + ) throws IOException + { + + User user = userService.getUserById(id); + String encryptedPassword = ""; + if(password.equals(user.getPassword())) { + encryptedPassword = password; + }else { + encryptedPassword = userService.encryptPassword(password); + } + + String uploadedImage = userService.updateImage(oldImageName, image); + + user.setName(name); + user.setEmail(email); + user.setPassword(encryptedPassword); + user.setDob(dob); + if(uploadedImage != null) { + user.setImage(uploadedImage); + } + + userService.updateUser(user); + + redirectAttributes.addFlashAttribute("flashMessage","User updated successfully!"); + return "redirect:/"; + } + + + @GetMapping("users/{id}") + public String deleteUser(@PathVariable("id") Long id, + Model model, + RedirectAttributes redirectAttributes) { + userService.deleteUser(id); + redirectAttributes.addFlashAttribute("flashMessage","User deleted successfully!"); + return "redirect:/"; + } + + @GetMapping("/uploads/{imageName}") + public ResponseEntity getImage(@PathVariable String imageName) { + try { + + Path imagePath = Paths.get(UPLOAD_DIR).resolve(imageName); + Resource resource = new UrlResource(imagePath.toUri()); + + if (resource.exists() && resource.isReadable()) { + MediaType mediaType = MediaTypeFactory.getMediaType(resource).orElse(MediaType.IMAGE_JPEG); + return ResponseEntity.ok() + .contentType(mediaType) + .body(resource); + } else { + return ResponseEntity.notFound().build(); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); + } + } + + + +} diff --git a/src/main/java/com/crudapp/entity/User.java b/src/main/java/com/crudapp/entity/User.java new file mode 100644 index 0000000..f03bd90 --- /dev/null +++ b/src/main/java/com/crudapp/entity/User.java @@ -0,0 +1,112 @@ +package com.crudapp.entity; + +import java.io.File; +import java.sql.Date; +import java.text.SimpleDateFormat; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.UniqueConstraint; + + +@Entity +@Table(name="users", uniqueConstraints={@UniqueConstraint(columnNames ={"email"})}) +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String name; + private Date dob; + private String email; + private String password; + private String image; + + public User() {} + + public User(String name, Date dob, String email, String password, String image) { + super(); + + this.name = name; + this.dob = dob; + this.email = email; + this.password = password; + this.image = image; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Date getDob() { + return dob; + } + + public void setDob(Date dob) { + this.dob = dob; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public String getFormattedDob() { + SimpleDateFormat d = new SimpleDateFormat("dd MMM yyyy"); + return d.format(dob); + } + public String getImageUrl() { + + if(image == null) { + return "/images/user.png"; + }else { + String UPLOAD_DIR = System.getProperty("user.dir") + "/src/main/resources/static/uploads/"; + if(new File((UPLOAD_DIR + image.trim())).exists()) { + return "/uploads/" + image.trim(); + } + else { + return"/images/user.png"; + } + } + + + + + } + +} diff --git a/src/main/java/com/crudapp/repository/UserRepository.java b/src/main/java/com/crudapp/repository/UserRepository.java new file mode 100644 index 0000000..f6f481f --- /dev/null +++ b/src/main/java/com/crudapp/repository/UserRepository.java @@ -0,0 +1,9 @@ +package com.crudapp.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.crudapp.entity.User; + +public interface UserRepository extends JpaRepository { + +} diff --git a/src/main/java/com/crudapp/service/UserService.java b/src/main/java/com/crudapp/service/UserService.java new file mode 100644 index 0000000..cc9377e --- /dev/null +++ b/src/main/java/com/crudapp/service/UserService.java @@ -0,0 +1,32 @@ +package com.crudapp.service; + +import java.io.IOException; +import java.util.List; + +import org.springframework.web.multipart.MultipartFile; + +import com.crudapp.entity.User; + +public interface UserService { + List getAllUsers(); + + List getUsersByPagination(int pageNo, int pageSize); + + Integer getUsersCount(); + + User getUserById(Long id); + + User saveUser(User user); + + User updateUser(User user); + + void deleteUser(Long id); + + String uploadImage(MultipartFile image) throws IOException; + + String updateImage(String oldImageName, MultipartFile image) throws IOException; + + String encryptPassword(String password); + + +} diff --git a/src/main/java/com/crudapp/service/impl/UserServiceImpl.java b/src/main/java/com/crudapp/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..b70e172 --- /dev/null +++ b/src/main/java/com/crudapp/service/impl/UserServiceImpl.java @@ -0,0 +1,123 @@ +package com.crudapp.service.impl; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.security.SecureRandom; +import java.util.List; +import java.util.UUID; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import com.crudapp.entity.User; +import com.crudapp.repository.UserRepository; +import com.crudapp.service.UserService; + +@Service +public class UserServiceImpl implements UserService { + + private UserRepository userRepository; + + private String UPLOAD_DIR = System.getProperty("user.dir") + + "/src/main/resources/static/uploads/"; + + Path rootLocation = Paths.get(UPLOAD_DIR); + + public UserServiceImpl(UserRepository userRepository) { + super(); + this.userRepository = userRepository; + } + + @Override + public List getAllUsers() { + return userRepository.findAll(); + } + + @Override + public Integer getUsersCount() { + return (int) userRepository.count(); + } + + + @Override + public List getUsersByPagination(int pageNo, int pageSize) { + + PageRequest pageReq = PageRequest.of(pageNo-1, pageSize); + Page page = userRepository.findAll(pageReq); + + return page.getContent(); + } + + @Override + public User getUserById(Long id) { + return userRepository.findById(id).get(); + } + + @Override + public User saveUser(User user) { + return userRepository.save(user); + } + + @Override + public User updateUser(User user) { + return userRepository.save(user); + } + + @Override + public void deleteUser(Long id) { + userRepository.deleteById(id); + } + + @Override + public String uploadImage(MultipartFile image) throws IOException { + + if(image != null && !image.isEmpty()) { + + String originalFilename = image.getOriginalFilename(); + String extension = originalFilename.substring(originalFilename.lastIndexOf('.')); + String uniqueName = UUID.randomUUID().toString() + extension; + + Path path = Paths.get(UPLOAD_DIR + uniqueName); + Files.write(path, image.getBytes()); + + System.out.println("UPLOAD PATH : " + UPLOAD_DIR + uniqueName); + return uniqueName; + } + return null; + } + + @Override + public String encryptPassword(String password) { + int strength = 10; + BCryptPasswordEncoder bCryptPasswordEncoder = + new BCryptPasswordEncoder(strength, new SecureRandom()); + String encodedPassword = bCryptPasswordEncoder.encode(password); + + return encodedPassword; + } + + @Override + public String updateImage(String oldImageName, MultipartFile image) throws IOException { + + if(image != null && !image.isEmpty()) { + File oldImage = new File(UPLOAD_DIR + oldImageName); + if(oldImage.exists() && oldImage.isFile()) { + oldImage.delete(); + } + } + return uploadImage(image); + } + + + + + + + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..fb002ac --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,19 @@ + +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.jpa.show-sql=true +spring.datasource.url=jdbc:mysql://localhost:3306/boot_crud_db?useSSL=false +spring.datasource.username=root +spring.datasource.password= + +# Hibernate properties +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect + +#Hibernate : create, create-drop +spring.jpa.hibernate.ddl-auto=update + +#logging.level.org.hibernate.sql=DEBUG + + +spring.servlet.multipart.max-file-size = 5MB +spring.servlet.multipart.max-request-size = 5MB +upload.directory=/ \ No newline at end of file diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css new file mode 100644 index 0000000..267f497 --- /dev/null +++ b/src/main/resources/static/css/style.css @@ -0,0 +1,105 @@ + +@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap'); + +:root{ + --grey : rgba(216, 216, 216, 0.76); + --light : white; + --primary: rgb(107, 87, 124); +} + + +body { + font-family: "Poppins", sans-serif; + font-weight: 500; + font-style: normal; + background: var(--grey); + + } + +.card{ + width: 95vw; + max-width: 65rem; + border-radius: 15px; + font-size: smaller; +} +.scroll-box{ + overflow-y: scroll; + scrollbar-width: none; + -ms-overflow-style: none; + max-height: 400px; +} +.scroll-box::-webkit-scrollbar{ + height: 0; + width: 0; +} +.background-flexbox{ + display: flex; + align-items: center; + justify-content: center; + height: 100vh; + width: 100vw; + min-width: fit-content; +} +.background-flexbox .card{ + min-width: fit-content; +} + +.action-btns button{ + display: flex !important; + align-items: center !important; + justify-content: center !important; +} + + +.action-btns button .bx{ + font-size: 33px; +} +.action-btns a{ + display: flex !important; + align-items: center !important; + justify-content: center !important; +} +.action-btns a .bx{ + font-size: 33px; +} +.action-btns{ + display: flex; + align-items: center; + justify-content: center; +} + +.background-flexbox table td .user{ + display: flex; + width: 100%; + height: 100%; + align-items: center; +} + +.background-flexbox table td .user img{ + width: 30px; + height: 30px; + border-radius: 50%; + margin-right: 5px; +} + +.update-profile-pic { + width: 100%; + height: fit-content; + display: flex; + align-items: center; + justify-content: space-between; + +} + +.update-profile-pic img{ + width: 40px; + height: 40px; + border-radius: 50%; + margin-right: 5px; +} + +@media screen and(max-width=600px){ + .action-btns{ + flex-direction: column; + } +} \ No newline at end of file diff --git a/src/main/resources/static/images/user.png b/src/main/resources/static/images/user.png new file mode 100644 index 0000000..aadb4a5 Binary files /dev/null and b/src/main/resources/static/images/user.png differ diff --git a/src/main/resources/static/uploads/142dd4d3-e990-4e04-804a-a6d043169d7d.png b/src/main/resources/static/uploads/142dd4d3-e990-4e04-804a-a6d043169d7d.png new file mode 100644 index 0000000..4d9848a Binary files /dev/null and b/src/main/resources/static/uploads/142dd4d3-e990-4e04-804a-a6d043169d7d.png differ diff --git a/src/main/resources/static/uploads/344b8e31-4858-4580-b815-ce7cf8b8cc5a.jpg b/src/main/resources/static/uploads/344b8e31-4858-4580-b815-ce7cf8b8cc5a.jpg new file mode 100644 index 0000000..ca1f76d Binary files /dev/null and b/src/main/resources/static/uploads/344b8e31-4858-4580-b815-ce7cf8b8cc5a.jpg differ diff --git a/src/main/resources/static/uploads/4cd5df41-4675-4cbf-99b9-ec033f961899.jpg b/src/main/resources/static/uploads/4cd5df41-4675-4cbf-99b9-ec033f961899.jpg new file mode 100644 index 0000000..034e33a Binary files /dev/null and b/src/main/resources/static/uploads/4cd5df41-4675-4cbf-99b9-ec033f961899.jpg differ diff --git a/src/main/resources/static/uploads/4e2cc88c-37d6-4ac2-9c9d-dbe9132b77df.jpg b/src/main/resources/static/uploads/4e2cc88c-37d6-4ac2-9c9d-dbe9132b77df.jpg new file mode 100644 index 0000000..ee883d3 Binary files /dev/null and b/src/main/resources/static/uploads/4e2cc88c-37d6-4ac2-9c9d-dbe9132b77df.jpg differ diff --git a/src/main/resources/static/uploads/4fb92ab0-4f6b-4849-aa8c-7d778348b938.jpeg b/src/main/resources/static/uploads/4fb92ab0-4f6b-4849-aa8c-7d778348b938.jpeg new file mode 100644 index 0000000..6f7f6ef Binary files /dev/null and b/src/main/resources/static/uploads/4fb92ab0-4f6b-4849-aa8c-7d778348b938.jpeg differ diff --git a/src/main/resources/static/uploads/584bd0de-0cb6-4171-8984-4b1fb122ff9c.png b/src/main/resources/static/uploads/584bd0de-0cb6-4171-8984-4b1fb122ff9c.png new file mode 100644 index 0000000..f726366 Binary files /dev/null and b/src/main/resources/static/uploads/584bd0de-0cb6-4171-8984-4b1fb122ff9c.png differ diff --git a/src/main/resources/static/uploads/7ceb4b03-0099-4bf7-9752-632174b0070c.png b/src/main/resources/static/uploads/7ceb4b03-0099-4bf7-9752-632174b0070c.png new file mode 100644 index 0000000..686f34d Binary files /dev/null and b/src/main/resources/static/uploads/7ceb4b03-0099-4bf7-9752-632174b0070c.png differ diff --git a/src/main/resources/static/uploads/7d59fcba-c6c1-4c94-a191-83269dea7340.jpg b/src/main/resources/static/uploads/7d59fcba-c6c1-4c94-a191-83269dea7340.jpg new file mode 100644 index 0000000..e7d139f Binary files /dev/null and b/src/main/resources/static/uploads/7d59fcba-c6c1-4c94-a191-83269dea7340.jpg differ diff --git a/src/main/resources/static/uploads/7f34866b-19c7-4b9e-b1a4-1e2c8120cc26.png b/src/main/resources/static/uploads/7f34866b-19c7-4b9e-b1a4-1e2c8120cc26.png new file mode 100644 index 0000000..9fd325a Binary files /dev/null and b/src/main/resources/static/uploads/7f34866b-19c7-4b9e-b1a4-1e2c8120cc26.png differ diff --git a/src/main/resources/static/uploads/84f24fbb-d53e-4b8b-9021-46b70a9921ce.jpg b/src/main/resources/static/uploads/84f24fbb-d53e-4b8b-9021-46b70a9921ce.jpg new file mode 100644 index 0000000..ca1f76d Binary files /dev/null and b/src/main/resources/static/uploads/84f24fbb-d53e-4b8b-9021-46b70a9921ce.jpg differ diff --git a/src/main/resources/static/uploads/8e4e79e7-a7aa-4938-aabe-50b69657cc78.png b/src/main/resources/static/uploads/8e4e79e7-a7aa-4938-aabe-50b69657cc78.png new file mode 100644 index 0000000..35d7306 Binary files /dev/null and b/src/main/resources/static/uploads/8e4e79e7-a7aa-4938-aabe-50b69657cc78.png differ diff --git a/src/main/resources/static/uploads/a8e85759-389d-4f6e-aa01-aa25bce61bb7.png b/src/main/resources/static/uploads/a8e85759-389d-4f6e-aa01-aa25bce61bb7.png new file mode 100644 index 0000000..0a38e2a Binary files /dev/null and b/src/main/resources/static/uploads/a8e85759-389d-4f6e-aa01-aa25bce61bb7.png differ diff --git a/src/main/resources/static/uploads/adefefb9-b7c6-43d6-a661-c4a1ae42cc53.png b/src/main/resources/static/uploads/adefefb9-b7c6-43d6-a661-c4a1ae42cc53.png new file mode 100644 index 0000000..adad57e Binary files /dev/null and b/src/main/resources/static/uploads/adefefb9-b7c6-43d6-a661-c4a1ae42cc53.png differ diff --git a/src/main/resources/static/uploads/b1341028-b9d6-4777-b0f6-97e11b3daea6.png b/src/main/resources/static/uploads/b1341028-b9d6-4777-b0f6-97e11b3daea6.png new file mode 100644 index 0000000..4d9848a Binary files /dev/null and b/src/main/resources/static/uploads/b1341028-b9d6-4777-b0f6-97e11b3daea6.png differ diff --git a/src/main/resources/static/uploads/cfb47473-369c-4be9-b3d0-a2bdbcdcfe38.jpg b/src/main/resources/static/uploads/cfb47473-369c-4be9-b3d0-a2bdbcdcfe38.jpg new file mode 100644 index 0000000..ebac5c8 Binary files /dev/null and b/src/main/resources/static/uploads/cfb47473-369c-4be9-b3d0-a2bdbcdcfe38.jpg differ diff --git a/src/main/resources/static/uploads/d0ca50b9-fb9b-4ce0-b151-ffc44a311095.png b/src/main/resources/static/uploads/d0ca50b9-fb9b-4ce0-b151-ffc44a311095.png new file mode 100644 index 0000000..f09d622 Binary files /dev/null and b/src/main/resources/static/uploads/d0ca50b9-fb9b-4ce0-b151-ffc44a311095.png differ diff --git a/src/main/resources/static/uploads/df7e399a-a4de-405e-81f2-a2b0c391537a.png b/src/main/resources/static/uploads/df7e399a-a4de-405e-81f2-a2b0c391537a.png new file mode 100644 index 0000000..eb903f9 Binary files /dev/null and b/src/main/resources/static/uploads/df7e399a-a4de-405e-81f2-a2b0c391537a.png differ diff --git a/src/main/resources/static/uploads/e660c999-5f1c-4ab4-af70-47a9cfc1b915.png b/src/main/resources/static/uploads/e660c999-5f1c-4ab4-af70-47a9cfc1b915.png new file mode 100644 index 0000000..9fd325a Binary files /dev/null and b/src/main/resources/static/uploads/e660c999-5f1c-4ab4-af70-47a9cfc1b915.png differ diff --git a/src/main/resources/static/uploads/e7e22016-eb79-434d-94d1-5f518e4203f5.ico b/src/main/resources/static/uploads/e7e22016-eb79-434d-94d1-5f518e4203f5.ico new file mode 100644 index 0000000..ca0acbb Binary files /dev/null and b/src/main/resources/static/uploads/e7e22016-eb79-434d-94d1-5f518e4203f5.ico differ diff --git a/src/main/resources/static/uploads/f841353f-2925-4216-9aa5-33f88df5a1e8.jpg b/src/main/resources/static/uploads/f841353f-2925-4216-9aa5-33f88df5a1e8.jpg new file mode 100644 index 0000000..99cf812 Binary files /dev/null and b/src/main/resources/static/uploads/f841353f-2925-4216-9aa5-33f88df5a1e8.jpg differ diff --git a/src/main/resources/static/uploads/fe73553f-676b-40be-8054-e4d0d45c005c.png b/src/main/resources/static/uploads/fe73553f-676b-40be-8054-e4d0d45c005c.png new file mode 100644 index 0000000..4d9848a Binary files /dev/null and b/src/main/resources/static/uploads/fe73553f-676b-40be-8054-e4d0d45c005c.png differ diff --git a/src/main/resources/templates/create-new-user.html b/src/main/resources/templates/create-new-user.html new file mode 100644 index 0000000..ee6e1b3 --- /dev/null +++ b/src/main/resources/templates/create-new-user.html @@ -0,0 +1,90 @@ + + + + + + + CRUD + + + + + + + + + + +
+
+
+

Create User

+
+ +
+
+ + +
+
+ + +
+
+ + +
We'll never share your email with anyone else.
+
+
+ + +
+
+ + +
+ + +
+
+
+
+ +
+ + + + + \ No newline at end of file diff --git a/src/main/resources/templates/error/400.html b/src/main/resources/templates/error/400.html new file mode 100644 index 0000000..40f1e55 --- /dev/null +++ b/src/main/resources/templates/error/400.html @@ -0,0 +1,60 @@ + + + + + + + Internal Server Error + + + + + +
+

Bad Request

+

Sorry, this request is unauthorised.

+ +
+ + + diff --git a/src/main/resources/templates/error/404.html b/src/main/resources/templates/error/404.html new file mode 100644 index 0000000..8848764 --- /dev/null +++ b/src/main/resources/templates/error/404.html @@ -0,0 +1,60 @@ + + + + + + + Internal Server Error + + + + + +
+

Page Not Found

+

Are you trying to get a resource which is unavailable!

+ +
+ + + diff --git a/src/main/resources/templates/error/500.html b/src/main/resources/templates/error/500.html new file mode 100644 index 0000000..054b494 --- /dev/null +++ b/src/main/resources/templates/error/500.html @@ -0,0 +1,60 @@ + + + + + + + Internal Server Error + + + + + +
+

Internal Server Error

+

Sorry, something went wrong on our end. We're working to fix it. Please try again later.

+ +
+ + + diff --git a/src/main/resources/templates/update-user.html b/src/main/resources/templates/update-user.html new file mode 100644 index 0000000..135a4f3 --- /dev/null +++ b/src/main/resources/templates/update-user.html @@ -0,0 +1,100 @@ + + + + + + + CRUD + + + + + + + + + + +
+
+
+

Update User

+
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + + +
We'll never share your email with anyone else.
+
+
+ + +
+
+ +
+ profile-image + + +
+
+ + +
+
+
+
+ +
+ + + + + \ No newline at end of file diff --git a/src/main/resources/templates/users.html b/src/main/resources/templates/users.html new file mode 100644 index 0000000..a0574b4 --- /dev/null +++ b/src/main/resources/templates/users.html @@ -0,0 +1,114 @@ + + + + + + + CRUD + + + + + + + + + + +
+
+
+
+

CRUD Application

+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + +
#NameDOBEmailActions
+
+ profile picture + +
+
+
+ + + + + + + + +
+ +
+
+ + + +
+
+ +
+ + + + + \ No newline at end of file diff --git a/src/test/java/com/runner/SpringBootCrudApplicationTests.java b/src/test/java/com/runner/SpringBootCrudApplicationTests.java new file mode 100644 index 0000000..c8dd5f1 --- /dev/null +++ b/src/test/java/com/runner/SpringBootCrudApplicationTests.java @@ -0,0 +1,13 @@ +package com.runner; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class SpringBootCrudApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/target/classes/application.properties b/target/classes/application.properties new file mode 100644 index 0000000..fb002ac --- /dev/null +++ b/target/classes/application.properties @@ -0,0 +1,19 @@ + +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.jpa.show-sql=true +spring.datasource.url=jdbc:mysql://localhost:3306/boot_crud_db?useSSL=false +spring.datasource.username=root +spring.datasource.password= + +# Hibernate properties +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect + +#Hibernate : create, create-drop +spring.jpa.hibernate.ddl-auto=update + +#logging.level.org.hibernate.sql=DEBUG + + +spring.servlet.multipart.max-file-size = 5MB +spring.servlet.multipart.max-request-size = 5MB +upload.directory=/ \ No newline at end of file diff --git a/target/classes/com/crudapp/ServletInitializer.class b/target/classes/com/crudapp/ServletInitializer.class new file mode 100644 index 0000000..4702a26 Binary files /dev/null and b/target/classes/com/crudapp/ServletInitializer.class differ diff --git a/target/classes/com/crudapp/SpringBootCrudApplication.class b/target/classes/com/crudapp/SpringBootCrudApplication.class new file mode 100644 index 0000000..3e2db16 Binary files /dev/null and b/target/classes/com/crudapp/SpringBootCrudApplication.class differ diff --git a/target/classes/com/crudapp/controller/UserController.class b/target/classes/com/crudapp/controller/UserController.class new file mode 100644 index 0000000..16b4483 Binary files /dev/null and b/target/classes/com/crudapp/controller/UserController.class differ diff --git a/target/classes/com/crudapp/entity/User.class b/target/classes/com/crudapp/entity/User.class new file mode 100644 index 0000000..454457c Binary files /dev/null and b/target/classes/com/crudapp/entity/User.class differ diff --git a/target/classes/com/crudapp/repository/UserRepository.class b/target/classes/com/crudapp/repository/UserRepository.class new file mode 100644 index 0000000..a19f8c4 Binary files /dev/null and b/target/classes/com/crudapp/repository/UserRepository.class differ diff --git a/target/classes/com/crudapp/service/UserService.class b/target/classes/com/crudapp/service/UserService.class new file mode 100644 index 0000000..468c893 Binary files /dev/null and b/target/classes/com/crudapp/service/UserService.class differ diff --git a/target/classes/com/crudapp/service/impl/UserServiceImpl.class b/target/classes/com/crudapp/service/impl/UserServiceImpl.class new file mode 100644 index 0000000..9d0845a Binary files /dev/null and b/target/classes/com/crudapp/service/impl/UserServiceImpl.class differ diff --git a/target/classes/static/css/style.css b/target/classes/static/css/style.css new file mode 100644 index 0000000..267f497 --- /dev/null +++ b/target/classes/static/css/style.css @@ -0,0 +1,105 @@ + +@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap'); + +:root{ + --grey : rgba(216, 216, 216, 0.76); + --light : white; + --primary: rgb(107, 87, 124); +} + + +body { + font-family: "Poppins", sans-serif; + font-weight: 500; + font-style: normal; + background: var(--grey); + + } + +.card{ + width: 95vw; + max-width: 65rem; + border-radius: 15px; + font-size: smaller; +} +.scroll-box{ + overflow-y: scroll; + scrollbar-width: none; + -ms-overflow-style: none; + max-height: 400px; +} +.scroll-box::-webkit-scrollbar{ + height: 0; + width: 0; +} +.background-flexbox{ + display: flex; + align-items: center; + justify-content: center; + height: 100vh; + width: 100vw; + min-width: fit-content; +} +.background-flexbox .card{ + min-width: fit-content; +} + +.action-btns button{ + display: flex !important; + align-items: center !important; + justify-content: center !important; +} + + +.action-btns button .bx{ + font-size: 33px; +} +.action-btns a{ + display: flex !important; + align-items: center !important; + justify-content: center !important; +} +.action-btns a .bx{ + font-size: 33px; +} +.action-btns{ + display: flex; + align-items: center; + justify-content: center; +} + +.background-flexbox table td .user{ + display: flex; + width: 100%; + height: 100%; + align-items: center; +} + +.background-flexbox table td .user img{ + width: 30px; + height: 30px; + border-radius: 50%; + margin-right: 5px; +} + +.update-profile-pic { + width: 100%; + height: fit-content; + display: flex; + align-items: center; + justify-content: space-between; + +} + +.update-profile-pic img{ + width: 40px; + height: 40px; + border-radius: 50%; + margin-right: 5px; +} + +@media screen and(max-width=600px){ + .action-btns{ + flex-direction: column; + } +} \ No newline at end of file diff --git a/target/classes/static/images/user.png b/target/classes/static/images/user.png new file mode 100644 index 0000000..aadb4a5 Binary files /dev/null and b/target/classes/static/images/user.png differ diff --git a/target/classes/static/uploads/344b8e31-4858-4580-b815-ce7cf8b8cc5a.jpg b/target/classes/static/uploads/344b8e31-4858-4580-b815-ce7cf8b8cc5a.jpg new file mode 100644 index 0000000..ca1f76d Binary files /dev/null and b/target/classes/static/uploads/344b8e31-4858-4580-b815-ce7cf8b8cc5a.jpg differ diff --git a/target/classes/static/uploads/4cd5df41-4675-4cbf-99b9-ec033f961899.jpg b/target/classes/static/uploads/4cd5df41-4675-4cbf-99b9-ec033f961899.jpg new file mode 100644 index 0000000..034e33a Binary files /dev/null and b/target/classes/static/uploads/4cd5df41-4675-4cbf-99b9-ec033f961899.jpg differ diff --git a/target/classes/static/uploads/4e2cc88c-37d6-4ac2-9c9d-dbe9132b77df.jpg b/target/classes/static/uploads/4e2cc88c-37d6-4ac2-9c9d-dbe9132b77df.jpg new file mode 100644 index 0000000..ee883d3 Binary files /dev/null and b/target/classes/static/uploads/4e2cc88c-37d6-4ac2-9c9d-dbe9132b77df.jpg differ diff --git a/target/classes/static/uploads/4fb92ab0-4f6b-4849-aa8c-7d778348b938.jpeg b/target/classes/static/uploads/4fb92ab0-4f6b-4849-aa8c-7d778348b938.jpeg new file mode 100644 index 0000000..6f7f6ef Binary files /dev/null and b/target/classes/static/uploads/4fb92ab0-4f6b-4849-aa8c-7d778348b938.jpeg differ diff --git a/target/classes/static/uploads/584bd0de-0cb6-4171-8984-4b1fb122ff9c.png b/target/classes/static/uploads/584bd0de-0cb6-4171-8984-4b1fb122ff9c.png new file mode 100644 index 0000000..f726366 Binary files /dev/null and b/target/classes/static/uploads/584bd0de-0cb6-4171-8984-4b1fb122ff9c.png differ diff --git a/target/classes/static/uploads/68df8c60-96cc-4d08-9bba-3af0ced763db.png b/target/classes/static/uploads/68df8c60-96cc-4d08-9bba-3af0ced763db.png new file mode 100644 index 0000000..a2cdbb4 Binary files /dev/null and b/target/classes/static/uploads/68df8c60-96cc-4d08-9bba-3af0ced763db.png differ diff --git a/target/classes/static/uploads/7ceb4b03-0099-4bf7-9752-632174b0070c.png b/target/classes/static/uploads/7ceb4b03-0099-4bf7-9752-632174b0070c.png new file mode 100644 index 0000000..686f34d Binary files /dev/null and b/target/classes/static/uploads/7ceb4b03-0099-4bf7-9752-632174b0070c.png differ diff --git a/target/classes/static/uploads/7d59fcba-c6c1-4c94-a191-83269dea7340.jpg b/target/classes/static/uploads/7d59fcba-c6c1-4c94-a191-83269dea7340.jpg new file mode 100644 index 0000000..e7d139f Binary files /dev/null and b/target/classes/static/uploads/7d59fcba-c6c1-4c94-a191-83269dea7340.jpg differ diff --git a/target/classes/static/uploads/7f34866b-19c7-4b9e-b1a4-1e2c8120cc26.png b/target/classes/static/uploads/7f34866b-19c7-4b9e-b1a4-1e2c8120cc26.png new file mode 100644 index 0000000..9fd325a Binary files /dev/null and b/target/classes/static/uploads/7f34866b-19c7-4b9e-b1a4-1e2c8120cc26.png differ diff --git a/target/classes/static/uploads/84f24fbb-d53e-4b8b-9021-46b70a9921ce.jpg b/target/classes/static/uploads/84f24fbb-d53e-4b8b-9021-46b70a9921ce.jpg new file mode 100644 index 0000000..ca1f76d Binary files /dev/null and b/target/classes/static/uploads/84f24fbb-d53e-4b8b-9021-46b70a9921ce.jpg differ diff --git a/target/classes/static/uploads/8e4e79e7-a7aa-4938-aabe-50b69657cc78.png b/target/classes/static/uploads/8e4e79e7-a7aa-4938-aabe-50b69657cc78.png new file mode 100644 index 0000000..35d7306 Binary files /dev/null and b/target/classes/static/uploads/8e4e79e7-a7aa-4938-aabe-50b69657cc78.png differ diff --git a/target/classes/static/uploads/a8e85759-389d-4f6e-aa01-aa25bce61bb7.png b/target/classes/static/uploads/a8e85759-389d-4f6e-aa01-aa25bce61bb7.png new file mode 100644 index 0000000..0a38e2a Binary files /dev/null and b/target/classes/static/uploads/a8e85759-389d-4f6e-aa01-aa25bce61bb7.png differ diff --git a/target/classes/static/uploads/adefefb9-b7c6-43d6-a661-c4a1ae42cc53.png b/target/classes/static/uploads/adefefb9-b7c6-43d6-a661-c4a1ae42cc53.png new file mode 100644 index 0000000..adad57e Binary files /dev/null and b/target/classes/static/uploads/adefefb9-b7c6-43d6-a661-c4a1ae42cc53.png differ diff --git a/target/classes/static/uploads/b1341028-b9d6-4777-b0f6-97e11b3daea6.png b/target/classes/static/uploads/b1341028-b9d6-4777-b0f6-97e11b3daea6.png new file mode 100644 index 0000000..4d9848a Binary files /dev/null and b/target/classes/static/uploads/b1341028-b9d6-4777-b0f6-97e11b3daea6.png differ diff --git a/target/classes/static/uploads/carousel2.jpg b/target/classes/static/uploads/carousel2.jpg new file mode 100644 index 0000000..ee883d3 Binary files /dev/null and b/target/classes/static/uploads/carousel2.jpg differ diff --git a/target/classes/static/uploads/cfb47473-369c-4be9-b3d0-a2bdbcdcfe38.jpg b/target/classes/static/uploads/cfb47473-369c-4be9-b3d0-a2bdbcdcfe38.jpg new file mode 100644 index 0000000..ebac5c8 Binary files /dev/null and b/target/classes/static/uploads/cfb47473-369c-4be9-b3d0-a2bdbcdcfe38.jpg differ diff --git a/target/classes/static/uploads/d0ca50b9-fb9b-4ce0-b151-ffc44a311095.png b/target/classes/static/uploads/d0ca50b9-fb9b-4ce0-b151-ffc44a311095.png new file mode 100644 index 0000000..f09d622 Binary files /dev/null and b/target/classes/static/uploads/d0ca50b9-fb9b-4ce0-b151-ffc44a311095.png differ diff --git a/target/classes/static/uploads/e660c999-5f1c-4ab4-af70-47a9cfc1b915.png b/target/classes/static/uploads/e660c999-5f1c-4ab4-af70-47a9cfc1b915.png new file mode 100644 index 0000000..9fd325a Binary files /dev/null and b/target/classes/static/uploads/e660c999-5f1c-4ab4-af70-47a9cfc1b915.png differ diff --git a/target/classes/static/uploads/e7e22016-eb79-434d-94d1-5f518e4203f5.ico b/target/classes/static/uploads/e7e22016-eb79-434d-94d1-5f518e4203f5.ico new file mode 100644 index 0000000..ca0acbb Binary files /dev/null and b/target/classes/static/uploads/e7e22016-eb79-434d-94d1-5f518e4203f5.ico differ diff --git a/target/classes/static/uploads/f841353f-2925-4216-9aa5-33f88df5a1e8.jpg b/target/classes/static/uploads/f841353f-2925-4216-9aa5-33f88df5a1e8.jpg new file mode 100644 index 0000000..99cf812 Binary files /dev/null and b/target/classes/static/uploads/f841353f-2925-4216-9aa5-33f88df5a1e8.jpg differ diff --git a/target/classes/static/uploads/fe73553f-676b-40be-8054-e4d0d45c005c.png b/target/classes/static/uploads/fe73553f-676b-40be-8054-e4d0d45c005c.png new file mode 100644 index 0000000..4d9848a Binary files /dev/null and b/target/classes/static/uploads/fe73553f-676b-40be-8054-e4d0d45c005c.png differ diff --git a/target/classes/static/uploads/logo.png b/target/classes/static/uploads/logo.png new file mode 100644 index 0000000..9fd325a Binary files /dev/null and b/target/classes/static/uploads/logo.png differ diff --git a/target/classes/templates/create-new-user.html b/target/classes/templates/create-new-user.html new file mode 100644 index 0000000..ee6e1b3 --- /dev/null +++ b/target/classes/templates/create-new-user.html @@ -0,0 +1,90 @@ + + + + + + + CRUD + + + + + + + + + + +
+
+
+

Create User

+
+ +
+
+ + +
+
+ + +
+
+ + +
We'll never share your email with anyone else.
+
+
+ + +
+
+ + +
+ + +
+
+
+
+ +
+ + + + + \ No newline at end of file diff --git a/target/classes/templates/error/404.html b/target/classes/templates/error/404.html new file mode 100644 index 0000000..6232301 --- /dev/null +++ b/target/classes/templates/error/404.html @@ -0,0 +1,60 @@ + + + + + + + Internal Server Error + + + + + +
+

Page Fot Found

+

Sorry, something went wrong on our end. We're working to fix it. Please try again later.

+ +
+ + + diff --git a/target/classes/templates/error/500.html b/target/classes/templates/error/500.html new file mode 100644 index 0000000..81f6e8c --- /dev/null +++ b/target/classes/templates/error/500.html @@ -0,0 +1,60 @@ + + + + + + + Internal Server Error + + + + + +
+

Internal Server Error

+

Sorry, something went wrong on our end. We're working to fix it. Please try again later.

+ +
+ + + diff --git a/target/classes/templates/update-user.html b/target/classes/templates/update-user.html new file mode 100644 index 0000000..135a4f3 --- /dev/null +++ b/target/classes/templates/update-user.html @@ -0,0 +1,100 @@ + + + + + + + CRUD + + + + + + + + + + +
+
+
+

Update User

+
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + + +
We'll never share your email with anyone else.
+
+
+ + +
+
+ +
+ profile-image + + +
+
+ + +
+
+
+
+ +
+ + + + + \ No newline at end of file diff --git a/target/classes/templates/users.html b/target/classes/templates/users.html new file mode 100644 index 0000000..a0574b4 --- /dev/null +++ b/target/classes/templates/users.html @@ -0,0 +1,114 @@ + + + + + + + CRUD + + + + + + + + + + +
+
+
+
+

CRUD Application

+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + +
#NameDOBEmailActions
+
+ profile picture + +
+
+
+ + + + + + + + +
+ +
+
+ + + +
+
+ +
+ + + + + \ No newline at end of file diff --git a/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF b/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..d3b943a --- /dev/null +++ b/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Build-Jdk-Spec: 17 +Implementation-Title: spring-boot-crud +Implementation-Version: 0.0.1-SNAPSHOT +Created-By: Maven Integration for Eclipse + diff --git a/target/m2e-wtp/web-resources/META-INF/maven/com.runner/spring-boot-crud/pom.properties b/target/m2e-wtp/web-resources/META-INF/maven/com.runner/spring-boot-crud/pom.properties new file mode 100644 index 0000000..d1d9e73 --- /dev/null +++ b/target/m2e-wtp/web-resources/META-INF/maven/com.runner/spring-boot-crud/pom.properties @@ -0,0 +1,7 @@ +#Generated by Maven Integration for Eclipse +#Sat Feb 24 18:55:25 IST 2024 +m2e.projectLocation=/home/personal/Documents/Spring workspace/spring-boot-crud +m2e.projectName=spring-boot-crud +groupId=com.runner +artifactId=spring-boot-crud +version=0.0.1-SNAPSHOT diff --git a/target/m2e-wtp/web-resources/META-INF/maven/com.runner/spring-boot-crud/pom.xml b/target/m2e-wtp/web-resources/META-INF/maven/com.runner/spring-boot-crud/pom.xml new file mode 100644 index 0000000..139c730 --- /dev/null +++ b/target/m2e-wtp/web-resources/META-INF/maven/com.runner/spring-boot-crud/pom.xml @@ -0,0 +1,69 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.2.2 + + + com.runner + spring-boot-crud + 0.0.1-SNAPSHOT + war + spring-boot-crud + crud-application using spring boot + + 21 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.mysql + mysql-connector-j + runtime + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/target/test-classes/com/runner/SpringBootCrudApplicationTests.class b/target/test-classes/com/runner/SpringBootCrudApplicationTests.class new file mode 100644 index 0000000..5f5353b Binary files /dev/null and b/target/test-classes/com/runner/SpringBootCrudApplicationTests.class differ