Browse Source

重新整理结构

ityouknow 8 years ago
parent
commit
dbea8ebad5
53 changed files with 1339 additions and 14 deletions
  1. 0 14
      mybatis-spring-boot/README.md
  2. 233 0
      spring-boot-helloWorld/mvnw
  3. 145 0
      spring-boot-helloWorld/mvnw.cmd
  4. 62 0
      spring-boot-helloWorld/pom.xml
  5. 12 0
      spring-boot-helloWorld/src/main/java/com/neo/Application.java
  6. 13 0
      spring-boot-helloWorld/src/main/java/com/neo/controller/HelloWorldController.java
  7. 0 0
      spring-boot-helloWorld/src/main/resources/application.properties
  8. 16 0
      spring-boot-helloWorld/src/test/java/com/neo/ApplicationTests.java
  9. 39 0
      spring-boot-helloWorld/src/test/java/com/neo/controller/HelloTests.java
  10. 37 0
      spring-boot-helloWorld/src/test/java/com/neo/controller/HelloWorldControlerTests.java
  11. 0 0
      spring-boot-mybatis-annotation/pom.xml
  12. 0 0
      spring-boot-mybatis-annotation/src/main/java/com/neo/Application.java
  13. 0 0
      spring-boot-mybatis-annotation/src/main/java/com/neo/entity/UserEntity.java
  14. 0 0
      spring-boot-mybatis-annotation/src/main/java/com/neo/enums/UserSexEnum.java
  15. 0 0
      spring-boot-mybatis-annotation/src/main/java/com/neo/mapper/UserMapper.java
  16. 0 0
      spring-boot-mybatis-annotation/src/main/java/com/neo/web/UserController.java
  17. 0 0
      spring-boot-mybatis-annotation/src/main/resources/application.properties
  18. 0 0
      spring-boot-mybatis-annotation/src/test/java/com/neo/ApplicationTests.java
  19. 0 0
      spring-boot-mybatis-annotation/src/test/java/com/neo/mapper/UserMapperTest.java
  20. 0 0
      spring-boot-mybatis-annotation/users.sql
  21. 0 0
      spring-boot-mybatis-xml/pom.xml
  22. 0 0
      spring-boot-mybatis-xml/src/main/java/com/neo/Application.java
  23. 0 0
      spring-boot-mybatis-xml/src/main/java/com/neo/entity/UserEntity.java
  24. 0 0
      spring-boot-mybatis-xml/src/main/java/com/neo/enums/UserSexEnum.java
  25. 0 0
      spring-boot-mybatis-xml/src/main/java/com/neo/mapper/UserMapper.java
  26. 0 0
      spring-boot-mybatis-xml/src/main/java/com/neo/web/UserController.java
  27. 0 0
      spring-boot-mybatis-xml/src/main/resources/application.properties
  28. 0 0
      spring-boot-mybatis-xml/src/main/resources/mybatis/mapper/UserMapper.xml
  29. 0 0
      spring-boot-mybatis-xml/src/main/resources/mybatis/mybatis-config.xml
  30. 0 0
      spring-boot-mybatis-xml/src/test/java/com/neo/ApplicationTests.java
  31. 0 0
      spring-boot-mybatis-xml/src/test/java/com/neo/mapper/UserMapperTest.java
  32. 30 0
      spring-boot-mybatis-xml/users.sql
  33. 90 0
      spring-boot-web/pom.xml
  34. 12 0
      spring-boot-web/src/main/java/com/neo/Application.java
  35. 60 0
      spring-boot-web/src/main/java/com/neo/WebConfiguration.java
  36. 63 0
      spring-boot-web/src/main/java/com/neo/config/RedisConfig.java
  37. 10 0
      spring-boot-web/src/main/java/com/neo/config/SessionConfig.java
  38. 76 0
      spring-boot-web/src/main/java/com/neo/domain/User.java
  39. 11 0
      spring-boot-web/src/main/java/com/neo/domain/UserRepository.java
  40. 26 0
      spring-boot-web/src/main/java/com/neo/util/NeoProperties.java
  41. 30 0
      spring-boot-web/src/main/java/com/neo/web/HelloController.java
  42. 26 0
      spring-boot-web/src/main/java/com/neo/web/ThymeleafController.java
  43. 34 0
      spring-boot-web/src/main/java/com/neo/web/UserController.java
  44. 32 0
      spring-boot-web/src/main/resources/application.properties
  45. 8 0
      spring-boot-web/src/main/resources/static/css/starter.css
  46. BIN
      spring-boot-web/src/main/resources/static/images/favicon.png
  47. 18 0
      spring-boot-web/src/main/resources/templates/hello.html
  48. 54 0
      spring-boot-web/src/main/resources/templates/layout.html
  49. 16 0
      spring-boot-web/src/test/java/com/neo/ApplicationTests.java
  50. 38 0
      spring-boot-web/src/test/java/com/neo/domain/UserRepositoryTests.java
  51. 52 0
      spring-boot-web/src/test/java/com/neo/util/TestRedis.java
  52. 57 0
      spring-boot-web/src/test/java/com/neo/web/HelloControlerTests.java
  53. 39 0
      spring-boot-web/src/test/java/com/neo/web/ProPertiesTest.java

+ 0 - 14
mybatis-spring-boot/README.md

@@ -1,14 +0,0 @@
-spring-boot-mybatis
-===========
-
-对Spring boot组合mybatis的学习,一个是注解版,一个是配置版
-
-
-mybatis和spring结合大大的减少了使用mybatis的配置,主要是使用[mybatis-spring-boot-starter](https://github.com/mybatis/spring-boot-starter)
-
-
-- [spring-boot-mybaits-annotation](https://github.com/ityouknow/spring-boot-starter/tree/master/mybatis-spring-boot/spring-boot-mybatis-annotation):注解版本
-
-- [spring-boot-mybaits-xml](https://github.com/ityouknow/spring-boot-starter/tree/master/mybatis-spring-boot/spring-boot-mybatis-xml):xml配置版本
-
-- users.sql :示例中的表结构

+ 233 - 0
spring-boot-helloWorld/mvnw

@@ -0,0 +1,233 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven2 Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+#   JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+#   M2_HOME - location of maven2's installed home dir
+#   MAVEN_OPTS - parameters passed to the Java VM when running Maven
+#     e.g. to debug Maven itself, use
+#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+  if [ -f /etc/mavenrc ] ; then
+    . /etc/mavenrc
+  fi
+
+  if [ -f "$HOME/.mavenrc" ] ; then
+    . "$HOME/.mavenrc"
+  fi
+
+fi
+
+# OS specific support.  $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+  CYGWIN*) cygwin=true ;;
+  MINGW*) mingw=true;;
+  Darwin*) darwin=true
+           #
+           # Look for the Apple JDKs first to preserve the existing behaviour, and then look
+           # for the new JDKs provided by Oracle.
+           #
+           if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
+             #
+             # Apple JDKs
+             #
+             export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
+           fi
+
+           if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
+             #
+             # Apple JDKs
+             #
+             export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
+           fi
+
+           if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
+             #
+             # Oracle JDKs
+             #
+             export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
+           fi
+
+           if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
+             #
+             # Apple JDKs
+             #
+             export JAVA_HOME=`/usr/libexec/java_home`
+           fi
+           ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+  if [ -r /etc/gentoo-release ] ; then
+    JAVA_HOME=`java-config --jre-home`
+  fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+  ## resolve links - $0 may be a link to maven's home
+  PRG="$0"
+
+  # need this for relative symlinks
+  while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+      PRG="$link"
+    else
+      PRG="`dirname "$PRG"`/$link"
+    fi
+  done
+
+  saveddir=`pwd`
+
+  M2_HOME=`dirname "$PRG"`/..
+
+  # make it fully qualified
+  M2_HOME=`cd "$M2_HOME" && pwd`
+
+  cd "$saveddir"
+  # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME=`cygpath --unix "$M2_HOME"`
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+  [ -n "$CLASSPATH" ] &&
+    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Migwn, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME="`(cd "$M2_HOME"; pwd)`"
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+  # TODO classpath?
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+  javaExecutable="`which javac`"
+  if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+    # readlink(1) is not available as standard on Solaris 10.
+    readLink=`which readlink`
+    if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+      if $darwin ; then
+        javaHome="`dirname \"$javaExecutable\"`"
+        javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+      else
+        javaExecutable="`readlink -f \"$javaExecutable\"`"
+      fi
+      javaHome="`dirname \"$javaExecutable\"`"
+      javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+      JAVA_HOME="$javaHome"
+      export JAVA_HOME
+    fi
+  fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+  if [ -n "$JAVA_HOME"  ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+      # IBM's JDK on AIX uses strange locations for the executables
+      JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+      JAVACMD="$JAVA_HOME/bin/java"
+    fi
+  else
+    JAVACMD="`which java`"
+  fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+  echo "Error: JAVA_HOME is not defined correctly." >&2
+  echo "  We cannot execute $JAVACMD" >&2
+  exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+  echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME=`cygpath --path --windows "$M2_HOME"`
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+  [ -n "$CLASSPATH" ] &&
+    CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+fi
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+  local basedir=$(pwd)
+  local wdir=$(pwd)
+  while [ "$wdir" != '/' ] ; do
+    if [ -d "$wdir"/.mvn ] ; then
+      basedir=$wdir
+      break
+    fi
+    wdir=$(cd "$wdir/.."; pwd)
+  done
+  echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+  if [ -f "$1" ]; then
+    echo "$(tr -s '\n' ' ' < "$1")"
+  fi
+}
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# 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
+
+exec "$JAVACMD" \
+  $MAVEN_OPTS \
+  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+  "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+  ${WRAPPER_LAUNCHER} "$@"

+ 145 - 0
spring-boot-helloWorld/mvnw.cmd

@@ -0,0 +1,145 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements.  See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership.  The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License.  You may obtain a copy of the License at
+@REM
+@REM    http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied.  See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven2 Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM     e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+set MAVEN_CMD_LINE_ARGS=%*
+
+@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="".\.mvn\wrapper\maven-wrapper.jar""
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
+
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+
+exit /B %ERROR_CODE%

+ 62 - 0
spring-boot-helloWorld/pom.xml

@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<groupId>com.neo</groupId>
+	<artifactId>springBoot</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<packaging>jar</packaging>
+
+	<name>springBoot</name>
+	<description>Demo project for Spring Boot</description>
+
+	<parent>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-parent</artifactId>
+		<version>1.3.6.RELEASE</version>
+		<relativePath/> <!-- lookup parent from repository -->
+	</parent>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<java.version>1.7</java.version>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter</artifactId>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+		
+		<dependency>
+	        <groupId>org.springframework.boot</groupId>
+	        <artifactId>spring-boot-starter-web</artifactId>
+	    </dependency>
+	     <dependency>
+	        <groupId>org.springframework.boot</groupId>
+	        <artifactId>spring-boot-devtools</artifactId>
+	        <optional>true</optional>
+		</dependency>
+	</dependencies>
+	
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+				<configuration>
+	                <fork>true</fork>
+	            </configuration>
+			</plugin>
+		</plugins>
+	</build>
+	
+
+</project>

+ 12 - 0
spring-boot-helloWorld/src/main/java/com/neo/Application.java

@@ -0,0 +1,12 @@
+package com.neo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Application {
+
+	public static void main(String[] args) {
+		SpringApplication.run(Application.class, args);
+	}
+}

+ 13 - 0
spring-boot-helloWorld/src/main/java/com/neo/controller/HelloWorldController.java

@@ -0,0 +1,13 @@
+package com.neo.controller;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class HelloWorldController {
+	
+    @RequestMapping("/hello")
+    public String index() {
+        return "Hello World xx";
+    }
+}

+ 0 - 0
spring-boot-helloWorld/src/main/resources/application.properties


+ 16 - 0
spring-boot-helloWorld/src/test/java/com/neo/ApplicationTests.java

@@ -0,0 +1,16 @@
+package com.neo;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = Application.class)
+public class ApplicationTests {
+
+	@Test
+	public void contextLoads() {
+	}
+
+}

+ 39 - 0
spring-boot-helloWorld/src/test/java/com/neo/controller/HelloTests.java

@@ -0,0 +1,39 @@
+package com.neo.controller;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.http.MediaType;
+import org.springframework.mock.web.MockServletContext;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = MockServletContext.class)
+@WebAppConfiguration
+public class HelloTests {
+
+	
+    private MockMvc mvc;
+
+    @Before
+    public void setUp() throws Exception {
+        mvc = MockMvcBuilders.standaloneSetup(new HelloWorldController()).build();
+    }
+
+    @Test
+    public void getHello() throws Exception {
+        mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON))
+                .andExpect(status().isOk())
+                .andExpect(content().string(equalTo("Hello World")));
+    }
+
+}

+ 37 - 0
spring-boot-helloWorld/src/test/java/com/neo/controller/HelloWorldControlerTests.java

@@ -0,0 +1,37 @@
+package com.neo.controller;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.http.MediaType;
+import org.springframework.mock.web.MockServletContext;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
+import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = MockServletContext.class)
+@WebAppConfiguration
+public class HelloWorldControlerTests {
+
+    private MockMvc mvc;
+
+    @Before
+    public void setUp() throws Exception {
+        mvc = MockMvcBuilders.standaloneSetup(new HelloWorldController()).build();
+    }
+
+    @Test
+    public void getHello() throws Exception {
+        mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON))
+                .andExpect(MockMvcResultMatchers.status().isOk())
+                .andDo(MockMvcResultHandlers.print())
+                .andReturn();
+    }
+
+}

+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-annotation/pom.xml → spring-boot-mybatis-annotation/pom.xml


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-annotation/src/main/java/com/neo/Application.java → spring-boot-mybatis-annotation/src/main/java/com/neo/Application.java


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-annotation/src/main/java/com/neo/entity/UserEntity.java → spring-boot-mybatis-annotation/src/main/java/com/neo/entity/UserEntity.java


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-annotation/src/main/java/com/neo/enums/UserSexEnum.java → spring-boot-mybatis-annotation/src/main/java/com/neo/enums/UserSexEnum.java


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-annotation/src/main/java/com/neo/mapper/UserMapper.java → spring-boot-mybatis-annotation/src/main/java/com/neo/mapper/UserMapper.java


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-annotation/src/main/java/com/neo/web/UserController.java → spring-boot-mybatis-annotation/src/main/java/com/neo/web/UserController.java


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-annotation/src/main/resources/application.properties → spring-boot-mybatis-annotation/src/main/resources/application.properties


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-annotation/src/test/java/com/neo/ApplicationTests.java → spring-boot-mybatis-annotation/src/test/java/com/neo/ApplicationTests.java


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-annotation/src/test/java/com/neo/mapper/UserMapperTest.java → spring-boot-mybatis-annotation/src/test/java/com/neo/mapper/UserMapperTest.java


+ 0 - 0
mybatis-spring-boot/users.sql → spring-boot-mybatis-annotation/users.sql


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-xml/pom.xml → spring-boot-mybatis-xml/pom.xml


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-xml/src/main/java/com/neo/Application.java → spring-boot-mybatis-xml/src/main/java/com/neo/Application.java


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-xml/src/main/java/com/neo/entity/UserEntity.java → spring-boot-mybatis-xml/src/main/java/com/neo/entity/UserEntity.java


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-xml/src/main/java/com/neo/enums/UserSexEnum.java → spring-boot-mybatis-xml/src/main/java/com/neo/enums/UserSexEnum.java


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-xml/src/main/java/com/neo/mapper/UserMapper.java → spring-boot-mybatis-xml/src/main/java/com/neo/mapper/UserMapper.java


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-xml/src/main/java/com/neo/web/UserController.java → spring-boot-mybatis-xml/src/main/java/com/neo/web/UserController.java


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-xml/src/main/resources/application.properties → spring-boot-mybatis-xml/src/main/resources/application.properties


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-xml/src/main/resources/mybatis/mapper/UserMapper.xml → spring-boot-mybatis-xml/src/main/resources/mybatis/mapper/UserMapper.xml


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-xml/src/main/resources/mybatis/mybatis-config.xml → spring-boot-mybatis-xml/src/main/resources/mybatis/mybatis-config.xml


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-xml/src/test/java/com/neo/ApplicationTests.java → spring-boot-mybatis-xml/src/test/java/com/neo/ApplicationTests.java


+ 0 - 0
mybatis-spring-boot/spring-boot-mybatis-xml/src/test/java/com/neo/mapper/UserMapperTest.java → spring-boot-mybatis-xml/src/test/java/com/neo/mapper/UserMapperTest.java


+ 30 - 0
spring-boot-mybatis-xml/users.sql

@@ -0,0 +1,30 @@
+/*
+Navicat MySQL Data Transfer
+
+Source Server         : 本地
+Source Server Version : 50505
+Source Host           : localhost:3306
+Source Database       : test1
+
+Target Server Type    : MYSQL
+Target Server Version : 50505
+File Encoding         : 65001
+
+Date: 2016-11-05 21:17:33
+*/
+
+SET FOREIGN_KEY_CHECKS=0;
+
+-- ----------------------------
+-- Table structure for `users`
+-- ----------------------------
+DROP TABLE IF EXISTS `users`;
+CREATE TABLE `users` (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
+  `userName` varchar(32) DEFAULT NULL COMMENT '用户名',
+  `passWord` varchar(32) DEFAULT NULL COMMENT '密码',
+  `user_sex` varchar(32) DEFAULT NULL,
+  `nick_name` varchar(32) DEFAULT NULL,
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8;
+

+ 90 - 0
spring-boot-web/pom.xml

@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<groupId>com.neo</groupId>
+	<artifactId>spring-boot-web</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<packaging>jar</packaging>
+
+	<name>spring-boot-web</name>
+	<description>Demo project for Spring Boot</description>
+
+	<parent>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-parent</artifactId>
+		<version>1.3.6.RELEASE</version>
+		<relativePath/> <!-- lookup parent from repository -->
+	</parent>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<java.version>1.7</java.version>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+	        <groupId>org.springframework.boot</groupId>
+	        <artifactId>spring-boot-starter-web</artifactId>
+	    </dependency>
+	    <dependency>
+	        <groupId>org.springframework.boot</groupId>
+	        <artifactId>spring-boot-starter-data-jpa</artifactId>
+	    </dependency>
+	     <dependency>
+	        <groupId>mysql</groupId>
+	        <artifactId>mysql-connector-java</artifactId>
+	    </dependency>
+	     <dependency>
+	        <groupId>org.springframework.boot</groupId>
+	        <artifactId>spring-boot-devtools</artifactId>
+	        <optional>true</optional>
+		</dependency>
+		<dependency>  
+		    <groupId>org.springframework.boot</groupId>
+		    <artifactId>spring-boot-starter-thymeleaf</artifactId>
+		</dependency> 
+		<dependency>
+		    <groupId>org.webjars.bower</groupId>
+		    <artifactId>jquery</artifactId>
+		    <version>2.0.3</version>
+		</dependency> 
+		<dependency>
+		    <groupId>org.webjars.bower</groupId>
+		    <artifactId>bootstrap</artifactId>
+		    <version>3.0.3</version>
+		</dependency>
+		<dependency>  
+		    <groupId>org.springframework.boot</groupId>  
+		    <artifactId>spring-boot-starter-redis</artifactId>  
+		</dependency>  
+		<dependency>
+		    <groupId>org.springframework.session</groupId>
+		    <artifactId>spring-session-data-redis</artifactId>
+		</dependency>
+	</dependencies>
+	
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+				<configuration>
+	                <fork>true</fork>
+	            </configuration>
+			</plugin>
+		</plugins>
+	</build>
+	
+
+</project>

+ 12 - 0
spring-boot-web/src/main/java/com/neo/Application.java

@@ -0,0 +1,12 @@
+package com.neo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Application {
+
+	public static void main(String[] args) {
+		SpringApplication.run(Application.class, args);
+	}
+}

+ 60 - 0
spring-boot-web/src/main/java/com/neo/WebConfiguration.java

@@ -0,0 +1,60 @@
+package com.neo;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.catalina.filters.RemoteIpFilter;
+import org.springframework.boot.context.embedded.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class WebConfiguration {
+    @Bean
+    public RemoteIpFilter remoteIpFilter() {
+        return new RemoteIpFilter();
+    }
+    
+    @Bean
+    public FilterRegistrationBean testFilterRegistration() {
+
+        FilterRegistrationBean registration = new FilterRegistrationBean();
+        registration.setFilter(new MyFilter());
+        registration.addUrlPatterns("/*");
+        registration.addInitParameter("paramName", "paramValue");
+        registration.setName("MyFilter");
+        registration.setOrder(1);
+        return registration;
+    }
+    
+    public class MyFilter implements Filter {
+		@Override
+		public void destroy() {
+			// TODO Auto-generated method stub
+		}
+
+		@Override
+		public void doFilter(ServletRequest srequest, ServletResponse sresponse, FilterChain filterChain)
+				throws IOException, ServletException {
+			// TODO Auto-generated method stub
+			HttpServletRequest request = (HttpServletRequest) srequest;
+			System.out.println("this is MyFilter,url :"+request.getRequestURI());
+			filterChain.doFilter(srequest, sresponse);
+		}
+
+		@Override
+		public void init(FilterConfig arg0) throws ServletException {
+			// TODO Auto-generated method stub
+		}
+    }
+}
+
+
+

+ 63 - 0
spring-boot-web/src/main/java/com/neo/config/RedisConfig.java

@@ -0,0 +1,63 @@
+package com.neo.config;
+
+import java.lang.reflect.Method;
+
+import org.springframework.cache.CacheManager;
+import org.springframework.cache.annotation.CachingConfigurerSupport;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.cache.interceptor.KeyGenerator;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Configuration
+@EnableCaching
+public class RedisConfig extends CachingConfigurerSupport{
+	
+	@Bean
+	public KeyGenerator keyGenerator() {
+        return new KeyGenerator() {
+            @Override
+            public Object generate(Object target, Method method, Object... params) {
+                StringBuilder sb = new StringBuilder();
+                sb.append(target.getClass().getName());
+                sb.append(method.getName());
+                for (Object obj : params) {
+                    sb.append(obj.toString());
+                }
+                return sb.toString();
+            }
+        };
+    }
+
+    @SuppressWarnings("rawtypes")
+    @Bean
+    public CacheManager cacheManager(RedisTemplate redisTemplate) {
+        RedisCacheManager rcm = new RedisCacheManager(redisTemplate);
+        //设置缓存过期时间
+        //rcm.setDefaultExpiration(60);//秒
+        return rcm;
+    }
+    
+    @Bean
+    public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
+        StringRedisTemplate template = new StringRedisTemplate(factory);
+        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
+        ObjectMapper om = new ObjectMapper();
+        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
+        jackson2JsonRedisSerializer.setObjectMapper(om);
+        template.setValueSerializer(jackson2JsonRedisSerializer);
+        template.afterPropertiesSet();
+        return template;
+    }
+
+}

+ 10 - 0
spring-boot-web/src/main/java/com/neo/config/SessionConfig.java

@@ -0,0 +1,10 @@
+package com.neo.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
+
+@Configuration
+@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 86400*30)
+public class SessionConfig {
+	
+}

+ 76 - 0
spring-boot-web/src/main/java/com/neo/domain/User.java

@@ -0,0 +1,76 @@
+package com.neo.domain;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class User implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+	@Id
+	@GeneratedValue
+	private Long id;
+	@Column(nullable = false, unique = true)
+	private String userName;
+	@Column(nullable = false)
+	private String passWord;
+	@Column(nullable = false, unique = true)
+	private String email;
+	@Column(nullable = true, unique = true)
+	private String nickName;
+	@Column(nullable = false)
+	private String regTime;
+
+	public User() {
+		super();
+	}
+	public User(String email, String nickName, String passWord, String userName, String regTime) {
+		super();
+		this.email = email;
+		this.nickName = nickName;
+		this.passWord = passWord;
+		this.userName = userName;
+		this.regTime = regTime;
+	}
+	public Long getId() {
+		return id;
+	}
+	public void setId(Long id) {
+		this.id = id;
+	}
+	public String getUserName() {
+		return userName;
+	}
+	public void setUserName(String userName) {
+		this.userName = userName;
+	}
+	public String getPassWord() {
+		return passWord;
+	}
+	public void setPassWord(String passWord) {
+		this.passWord = passWord;
+	}
+	public String getEmail() {
+		return email;
+	}
+	public void setEmail(String email) {
+		this.email = email;
+	}
+	public String getNickName() {
+		return nickName;
+	}
+	public void setNickName(String nickName) {
+		this.nickName = nickName;
+	}
+	public String getRegTime() {
+		return regTime;
+	}
+	public void setRegTime(String regTime) {
+		this.regTime = regTime;
+	}
+
+}

+ 11 - 0
spring-boot-web/src/main/java/com/neo/domain/UserRepository.java

@@ -0,0 +1,11 @@
+package com.neo.domain;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface UserRepository extends JpaRepository<User, Long> {
+
+    User findByUserName(String userName);
+
+    User findByUserNameOrEmail(String username, String email);
+    
+}

+ 26 - 0
spring-boot-web/src/main/java/com/neo/util/NeoProperties.java

@@ -0,0 +1,26 @@
+package com.neo.util;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+public class NeoProperties {
+	
+	@Value("${com.neo.title}")
+	private String title;
+	@Value("${com.neo.description}")
+	private String description;
+	public String getTitle() {
+		return title;
+	}
+	public void setTitle(String title) {
+		this.title = title;
+	}
+	public String getDescription() {
+		return description;
+	}
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+}

+ 30 - 0
spring-boot-web/src/main/java/com/neo/web/HelloController.java

@@ -0,0 +1,30 @@
+package com.neo.web;
+
+import java.util.Locale;
+import java.util.UUID;
+
+import javax.servlet.http.HttpSession;
+
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class HelloController {
+	
+    @RequestMapping("/hello")
+	public String hello(Locale locale, Model model) {
+		return "hello world";
+	}
+    
+    @RequestMapping("/uid")
+    String uid(HttpSession session) {
+        UUID uid = (UUID) session.getAttribute("uid");
+        if (uid == null) {
+            uid = UUID.randomUUID();
+        }
+        session.setAttribute("uid", uid);
+        return session.getId();
+    }
+
+}

+ 26 - 0
spring-boot-web/src/main/java/com/neo/web/ThymeleafController.java

@@ -0,0 +1,26 @@
+package com.neo.web;
+
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@Controller
+public class ThymeleafController {
+	
+    @RequestMapping("/hi")
+	public String hello(Locale locale, Model model) {
+		model.addAttribute("greeting", "Hello!");
+
+		Date date = new Date();
+		DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);        
+		String formattedDate = dateFormat.format(date);
+		model.addAttribute("currentTime", formattedDate);
+
+		return "hello";
+	}
+
+}

+ 34 - 0
spring-boot-web/src/main/java/com/neo/web/UserController.java

@@ -0,0 +1,34 @@
+package com.neo.web;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.neo.domain.User;
+import com.neo.domain.UserRepository;
+
+@RestController
+public class UserController {
+	
+	@Autowired
+	private UserRepository userRepository;
+	
+    @RequestMapping("/getUser")
+    @Cacheable(value="user-key")
+    public User getUser() {
+    	User user=userRepository.findByUserName("aa");
+    	System.out.println("若下面没出现“无缓存的时候调用”字样且能打印出数据表示测试成功");  
+        return user;
+    }
+    
+    @RequestMapping("/getUsers")
+    @Cacheable(value="key-Users")
+    public List<User> getUsers() {
+    	List<User> users=userRepository.findAll();
+    	System.out.println("若下面没出现“无缓存的时候调用”字样且能打印出数据表示测试成功");  
+        return users;
+    }
+}

+ 32 - 0
spring-boot-web/src/main/resources/application.properties

@@ -0,0 +1,32 @@
+spring.datasource.url=jdbc:mysql://localhost:3306/test
+spring.datasource.username=root
+spring.datasource.password=root
+spring.datasource.driver-class-name=com.mysql.jdbc.Driver
+
+spring.jpa.properties.hibernate.hbm2ddl.auto=update
+spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
+spring.jpa.show-sql= true
+
+com.neo.title=\u7eaf\u6d01\u7684\u5fae\u7b11
+com.neo.description=\u5206\u4eab\u751f\u6d3b\u548c\u6280\u672f
+
+# REDIS (RedisProperties)
+# Redis\u6570\u636e\u5e93\u7d22\u5f15\uff08\u9ed8\u8ba4\u4e3a0\uff09
+spring.redis.database=0  
+# Redis\u670d\u52a1\u5668\u5730\u5740
+spring.redis.host=192.168.0.58
+# Redis\u670d\u52a1\u5668\u8fde\u63a5\u7aef\u53e3
+spring.redis.port=6379  
+# Redis\u670d\u52a1\u5668\u8fde\u63a5\u5bc6\u7801\uff08\u9ed8\u8ba4\u4e3a\u7a7a\uff09
+spring.redis.password=  
+# \u8fde\u63a5\u6c60\u6700\u5927\u8fde\u63a5\u6570\uff08\u4f7f\u7528\u8d1f\u503c\u8868\u793a\u6ca1\u6709\u9650\u5236\uff09
+spring.redis.pool.max-active=8  
+# \u8fde\u63a5\u6c60\u6700\u5927\u963b\u585e\u7b49\u5f85\u65f6\u95f4\uff08\u4f7f\u7528\u8d1f\u503c\u8868\u793a\u6ca1\u6709\u9650\u5236\uff09
+spring.redis.pool.max-wait=-1  
+# \u8fde\u63a5\u6c60\u4e2d\u7684\u6700\u5927\u7a7a\u95f2\u8fde\u63a5
+spring.redis.pool.max-idle=8  
+# \u8fde\u63a5\u6c60\u4e2d\u7684\u6700\u5c0f\u7a7a\u95f2\u8fde\u63a5
+spring.redis.pool.min-idle=0  
+# \u8fde\u63a5\u8d85\u65f6\u65f6\u95f4\uff08\u6beb\u79d2\uff09
+spring.redis.timeout=0 
+

+ 8 - 0
spring-boot-web/src/main/resources/static/css/starter.css

@@ -0,0 +1,8 @@
+body {
+  padding-top: 50px;
+}
+
+.starter-template {
+  padding: 40px 15px;
+  text-align: center;
+}

BIN
spring-boot-web/src/main/resources/static/images/favicon.png


+ 18 - 0
spring-boot-web/src/main/resources/templates/hello.html

@@ -0,0 +1,18 @@
+<html xmlns:th="http://www.thymeleaf.org">
+  <head th:include="layout :: htmlhead" th:with="title='Hello'"></head>
+
+  <body>
+    <div th:replace="layout :: navbar">(navbar)</div>
+
+    <div class="container">
+      <div class="starter-template">
+        <h1>Spring MVC / Thymeleaf / Bootstrap</h1>
+        <p class="lead" th:text="${greeting}">(greeting)</p>
+        <p>The current time is <span th:text="${currentTime}">(time)</span></p>
+      </div>
+    </div>
+
+    <div th:include="layout :: footer" id="footer">(footer)</div>
+
+  </body>
+</html>

+ 54 - 0
spring-boot-web/src/main/resources/templates/layout.html

@@ -0,0 +1,54 @@
+<html xmlns:th="http://www.thymeleaf.org">
+  <head th:fragment="htmlhead">
+    <meta charset="utf-8"></meta>
+    <meta http-equiv="X-UA-Compatible" content="IE=edge"></meta>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
+    <meta name="description" content=""></meta>
+    <meta name="author" content=""></meta>
+    <link rel="shortcut icon" type="image/png" th:href="@{/images/favicon.png}"></link>
+
+   	<title th:text="${title}">(title)</title>
+
+  	<link th:href="@{/webjars/bootstrap/3.0.3/dist/css/bootstrap.css}" rel="stylesheet"></link>
+  	<link th:href="@{/css/starter.css}" rel="stylesheet"></link>
+  </head>
+
+  <body>
+    <div th:fragment="navbar" class="navbar navbar-inverse navbar-fixed-top" role="navigation">
+      <div class="container">
+        <div class="navbar-header">
+          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
+            <span class="sr-only">Toggle navigation</span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+          </button>
+          <a class="navbar-brand" href="#">Project name</a>
+        </div>
+        <div class="collapse navbar-collapse">
+          <ul class="nav navbar-nav">
+            <li class="active"><a href="#">Home</a></li>
+            <li><a href="#about">About</a></li>
+            <li><a href="#contact">Contact</a></li>
+          </ul>
+        </div>
+      </div>
+    </div>
+
+    <div class="container">
+      <div class="starter-template">
+        <h1>Spring MVC/Thymeleaf/Bootstrap</h1>
+        <p class="lead" th:text="${greeting}">(greeting)</p>
+      </div>
+    </div>
+
+    <div th:fragment="footer" id="footer">
+      <div class="container">
+        <p class="muted credit">Spring MVC/Thymeleaf/Bootstrap Project Template</p>
+      </div>
+      <script th:src="@{/webjars/jquery/2.0.3/jquery.min.js}"></script>
+      <script th:src="@{/webjars/bootstrap/3.0.3/js/bootstrap.min.js}"></script>
+    </div>
+
+  </body>
+</html>

+ 16 - 0
spring-boot-web/src/test/java/com/neo/ApplicationTests.java

@@ -0,0 +1,16 @@
+package com.neo;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = Application.class)
+public class ApplicationTests {
+
+	@Test
+	public void contextLoads() {
+	}
+
+}

+ 38 - 0
spring-boot-web/src/test/java/com/neo/domain/UserRepositoryTests.java

@@ -0,0 +1,38 @@
+package com.neo.domain;
+
+import java.text.DateFormat;
+import java.util.Date;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.neo.Application;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(Application.class)
+public class UserRepositoryTests {
+
+	@Autowired
+	private UserRepository userRepository;
+
+	@Test
+	public void test() throws Exception {
+		Date date = new Date();
+		DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);        
+		String formattedDate = dateFormat.format(date);
+		
+		userRepository.save(new User("aa1", "aa@126.com", "aa", "aa123456",formattedDate));
+		userRepository.save(new User("bb2", "bb@126.com", "bb", "bb123456",formattedDate));
+		userRepository.save(new User("cc3", "cc@126.com", "cc", "cc123456",formattedDate));
+
+		Assert.assertEquals(9, userRepository.findAll().size());
+		Assert.assertEquals("bb", userRepository.findByUserNameOrEmail("bb", "cc@126.com").getNickName());
+		userRepository.delete(userRepository.findByUserName("aa1"));
+	}
+
+}

+ 52 - 0
spring-boot-web/src/test/java/com/neo/util/TestRedis.java

@@ -0,0 +1,52 @@
+package com.neo.util;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.neo.Application;
+import com.neo.domain.User;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(Application.class)
+public class TestRedis {
+
+    @Autowired
+    private StringRedisTemplate stringRedisTemplate;
+    
+	@Autowired
+	private RedisTemplate redisTemplate;
+
+    @Test
+    public void test() throws Exception {
+        stringRedisTemplate.opsForValue().set("aaa", "111");
+        Assert.assertEquals("111", stringRedisTemplate.opsForValue().get("aaa"));
+    }
+    
+    @Test
+    public void testObj() throws Exception {
+        User user=new User("aa@126.com", "aa", "aa123456", "aa","123");
+        ValueOperations<String, User> operations=redisTemplate.opsForValue();
+        operations.set("com.neox", user);
+        operations.set("com.neo.f", user,1,TimeUnit.SECONDS);
+        Thread.sleep(1000);
+        //redisTemplate.delete("com.neo.f");
+        boolean exists=redisTemplate.hasKey("com.neo.f");
+        if(exists){
+        	System.out.println("exists is true");
+        }else{
+        	System.out.println("exists is false");
+        }
+       // Assert.assertEquals("aa", operations.get("com.neo.f").getUserName());
+    }
+
+
+}

+ 57 - 0
spring-boot-web/src/test/java/com/neo/web/HelloControlerTests.java

@@ -0,0 +1,57 @@
+package com.neo.web;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.http.MediaType;
+import org.springframework.mock.web.MockServletContext;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
+import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import com.neo.web.HelloController;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = MockServletContext.class)
+@WebAppConfiguration
+public class HelloControlerTests {
+
+    private MockMvc mvc;
+
+    @Before
+    public void setUp() throws Exception {
+        mvc = MockMvcBuilders.standaloneSetup(new HelloController()).build();
+    }
+
+    @Test
+    public void getHello() throws Exception {
+        mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON))
+                .andExpect(MockMvcResultMatchers.status().isOk())
+                .andDo(MockMvcResultHandlers.print())
+                .andReturn();
+    }
+    
+    
+
+    @Test
+    public void testHello() throws Exception {
+        mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON))
+                .andExpect(status().isOk())
+                .andExpect(content().string(equalTo("Hello World")));
+    }
+
+
+}

+ 39 - 0
spring-boot-web/src/test/java/com/neo/web/ProPertiesTest.java

@@ -0,0 +1,39 @@
+package com.neo.web;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.neo.Application;
+import com.neo.util.NeoProperties;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(Application.class)
+public class ProPertiesTest {
+
+	
+	@Autowired
+    private NeoProperties neoProperties;
+
+
+    @Test
+    public void getHello() throws Exception {
+    	System.out.println(neoProperties.getTitle());
+        Assert.assertEquals(neoProperties.getTitle(), "纯洁的微笑");
+        Assert.assertEquals(neoProperties.getDescription(), "分享生活和技术");
+    }
+
+    
+    @Test
+    public void testMap() throws Exception {
+    	Map<String, Long> orderMinTime=new HashMap<String, Long>();
+    	long xx=orderMinTime.get("123");
+    }
+
+}