Showing preview only (949K chars total). Download the full file or copy to clipboard to get everything.
Repository: dyc87112/SpringBoot-Learning
Branch: master
Commit: 4212d163da81
Files: 714
Total size: 743.5 KB
Directory structure:
gitextract_o44g23q_/
├── .gitignore
├── .gitmodules
├── 1.x/
│ ├── Chapter1/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Chapter1Application.java
│ │ │ │ └── web/
│ │ │ │ └── HelloController.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── Chapter1ApplicationTests.java
│ ├── Chapter2-1-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ ├── service/
│ │ │ │ │ └── BlogProperties.java
│ │ │ │ └── web/
│ │ │ │ └── HelloController.java
│ │ │ └── resources/
│ │ │ ├── application-dev.properties
│ │ │ ├── application-prod.properties
│ │ │ ├── application-test.properties
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter2-1-2/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ ├── Application.java
│ │ │ ├── ApplicationEnvironmentPreparedEventListener.java
│ │ │ ├── ApplicationFailedEventListener.java
│ │ │ ├── ApplicationPreparedEventListener.java
│ │ │ ├── ApplicationReadyEventListener.java
│ │ │ ├── ApplicationStartedEventListener.java
│ │ │ └── ApplicationStartingEventListener.java
│ │ └── resources/
│ │ ├── META-INF/
│ │ │ └── spring.factories
│ │ └── application.properties
│ ├── Chapter2-2-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ ├── Application.java
│ │ │ ├── FooProperties.java
│ │ │ └── PostInfo.java
│ │ └── resources/
│ │ └── application.properties
│ ├── Chapter3-1-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ ├── domain/
│ │ │ │ │ └── User.java
│ │ │ │ └── web/
│ │ │ │ ├── HelloController.java
│ │ │ │ └── UserController.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-1-2/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── web/
│ │ │ │ └── HelloController.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── templates/
│ │ │ └── index.html
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-1-3/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── web/
│ │ │ │ └── HelloController.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── templates/
│ │ │ └── index.ftl
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-1-4/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── web/
│ │ │ │ └── HelloController.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── templates/
│ │ │ └── index.vm
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-1-5/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ ├── Application.java
│ │ │ ├── Swagger2.java
│ │ │ ├── domain/
│ │ │ │ └── User.java
│ │ │ └── web/
│ │ │ ├── HelloController.java
│ │ │ └── UserController.java
│ │ └── resources/
│ │ └── application.properties
│ ├── Chapter3-1-6/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ ├── dto/
│ │ │ │ │ └── ErrorInfo.java
│ │ │ │ ├── exception/
│ │ │ │ │ ├── GlobalExceptionHandler.java
│ │ │ │ │ └── MyException.java
│ │ │ │ └── web/
│ │ │ │ └── HelloController.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── templates/
│ │ │ ├── error.html
│ │ │ └── index.html
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-1-7/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── Application.java
│ │ └── resources/
│ │ └── application.properties
│ ├── Chapter3-1-8/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ ├── Application.java
│ │ │ └── web/
│ │ │ ├── User.java
│ │ │ └── UserController.java
│ │ └── resources/
│ │ └── application.properties
│ ├── Chapter3-2-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── service/
│ │ │ │ ├── UserService.java
│ │ │ │ └── UserServiceImpl.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-2-10/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ ├── Person.java
│ │ │ │ └── PersonRepository.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── ApplicationTests.java
│ │ └── resources/
│ │ ├── application.properties
│ │ └── ldap-server.ldif
│ ├── Chapter3-2-11/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── Application.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-2-2/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── domain/
│ │ │ │ ├── User.java
│ │ │ │ └── UserRepository.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-2-3/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── DataSourceConfig.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-2-4/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ ├── DataSourceConfig.java
│ │ │ │ ├── PrimaryConfig.java
│ │ │ │ ├── SecondaryConfig.java
│ │ │ │ └── domain/
│ │ │ │ ├── p/
│ │ │ │ │ ├── User.java
│ │ │ │ │ └── UserRepository.java
│ │ │ │ └── s/
│ │ │ │ ├── Message.java
│ │ │ │ └── MessageRepository.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-2-5/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ ├── RedisConfig.java
│ │ │ │ ├── RedisObjectSerializer.java
│ │ │ │ └── domain/
│ │ │ │ └── User.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-2-6/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── domain/
│ │ │ │ ├── User.java
│ │ │ │ └── UserRepository.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-2-7/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── domain/
│ │ │ │ ├── User.java
│ │ │ │ └── UserMapper.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-2-8/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── domain/
│ │ │ │ ├── User.java
│ │ │ │ └── UserMapper.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-2-9/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── service/
│ │ │ │ ├── UserService.java
│ │ │ │ └── UserServiceImpl.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── db/
│ │ │ └── V1__Base_version.sql
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter3-3-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ ├── domain/
│ │ │ │ │ ├── User.java
│ │ │ │ │ └── UserRepository.java
│ │ │ │ └── service/
│ │ │ │ └── UserService.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter4-1-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── task/
│ │ │ │ └── ScheduledTasks.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter4-1-2/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── async/
│ │ │ │ └── Task.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter4-1-3/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── async/
│ │ │ │ └── Task.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter4-1-4/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── async/
│ │ │ │ └── Task.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter4-1-5/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── async/
│ │ │ │ └── Task.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter4-2-2/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── Application.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── log4j.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter4-2-3/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── Application.java
│ │ │ └── resources/
│ │ │ ├── application-dev.properties
│ │ │ ├── application-prod.properties
│ │ │ ├── application-test.properties
│ │ │ ├── application.properties
│ │ │ └── log4j.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter4-2-4/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ ├── aspect/
│ │ │ │ │ └── WebLogAspect.java
│ │ │ │ └── web/
│ │ │ │ └── HelloController.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── log4j.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter4-2-5/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ ├── aspect/
│ │ │ │ │ └── WebLogAspect.java
│ │ │ │ ├── log/
│ │ │ │ │ └── MongoAppender.java
│ │ │ │ └── web/
│ │ │ │ └── HelloController.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── log4j.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter4-2-6/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── DemoApplication.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── DemoApplicationTests.java
│ ├── Chapter4-3-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ ├── WebSecurityConfig.java
│ │ │ │ └── web/
│ │ │ │ └── HelloController.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── templates/
│ │ │ ├── hello.html
│ │ │ ├── index.html
│ │ │ └── login.html
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter4-4-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── domain/
│ │ │ │ ├── User.java
│ │ │ │ └── UserRepository.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── ehcache.xml
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter4-4-2/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── domain/
│ │ │ │ ├── User.java
│ │ │ │ └── UserRepository.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter4-5-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── Application.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── templates/
│ │ │ └── template.vm
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter5-2-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── HelloApplication.java
│ │ │ │ └── rabbit/
│ │ │ │ ├── RabbitConfig.java
│ │ │ │ ├── Receiver.java
│ │ │ │ └── Sender.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── HelloApplicationTests.java
│ ├── Chapter6-1-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ ├── Application.java
│ │ │ ├── EventConfig.java
│ │ │ ├── Events.java
│ │ │ ├── StateMachineConfig.java
│ │ │ └── States.java
│ │ └── resources/
│ │ └── application.properties
│ ├── Chapter6-2-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── web/
│ │ │ │ └── HelloController.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter9-1-1/
│ │ ├── compute-service/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ ├── main/
│ │ │ │ ├── java/
│ │ │ │ │ └── com/
│ │ │ │ │ └── didispace/
│ │ │ │ │ ├── ComputeServiceApplication.java
│ │ │ │ │ └── web/
│ │ │ │ │ └── ComputeController.java
│ │ │ │ └── resources/
│ │ │ │ └── application.properties
│ │ │ └── test/
│ │ │ └── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── ApplicationTests.java
│ │ └── eureka-server/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── Application.java
│ │ └── resources/
│ │ └── application.properties
│ ├── Chapter9-1-2/
│ │ ├── eureka-feign/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── FeignApplication.java
│ │ │ │ ├── service/
│ │ │ │ │ └── ComputeClient.java
│ │ │ │ └── web/
│ │ │ │ └── ConsumerController.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── eureka-ribbon/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ ├── RibbonApplication.java
│ │ │ └── web/
│ │ │ └── ConsumerController.java
│ │ └── resources/
│ │ └── application.properties
│ ├── Chapter9-1-3/
│ │ ├── compute-service/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ ├── main/
│ │ │ │ ├── java/
│ │ │ │ │ └── com/
│ │ │ │ │ └── didispace/
│ │ │ │ │ ├── ComputeServiceApplication.java
│ │ │ │ │ └── web/
│ │ │ │ │ └── ComputeController.java
│ │ │ │ └── resources/
│ │ │ │ └── application.properties
│ │ │ └── test/
│ │ │ └── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── ApplicationTests.java
│ │ ├── eureka-feign/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ ├── FeignApplication.java
│ │ │ ├── service/
│ │ │ │ ├── ComputeClient.java
│ │ │ │ └── ComputeClientHystrix.java
│ │ │ └── web/
│ │ │ └── ConsumerController.java
│ │ ├── eureka-ribbon/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ ├── RibbonApplication.java
│ │ │ ├── service/
│ │ │ │ └── ComputeService.java
│ │ │ └── web/
│ │ │ └── ConsumerController.java
│ │ └── eureka-server/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── Application.java
│ │ └── resources/
│ │ └── application.properties
│ ├── Chapter9-1-4/
│ │ ├── config-client/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── web/
│ │ │ │ └── TestController.java
│ │ │ └── resources/
│ │ │ └── bootstrap.properties
│ │ ├── config-repo/
│ │ │ ├── didispace-dev.properties
│ │ │ ├── didispace-prod.properties
│ │ │ ├── didispace-test.properties
│ │ │ └── didispace.properties
│ │ └── config-server/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── Application.java
│ │ └── resources/
│ │ ├── application.properties
│ │ ├── didispace-dev.properties
│ │ ├── didispace-prod.properties
│ │ ├── didispace-test.properties
│ │ └── didispace.properties
│ ├── Chapter9-1-5/
│ │ ├── api-gateway/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── filter/
│ │ │ │ └── AccessFilter.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ ├── eureka-server/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── Application.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ ├── service-A/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ ├── main/
│ │ │ │ ├── java/
│ │ │ │ │ └── com/
│ │ │ │ │ └── didispace/
│ │ │ │ │ ├── ComputeServiceApplication.java
│ │ │ │ │ └── web/
│ │ │ │ │ └── ComputeController.java
│ │ │ │ └── resources/
│ │ │ │ └── application.properties
│ │ │ └── test/
│ │ │ └── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── ApplicationTests.java
│ │ └── service-B/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── ComputeServiceApplication.java
│ │ │ │ └── web/
│ │ │ │ └── ComputeController.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter9-2-1/
│ │ ├── compute-service/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ ├── main/
│ │ │ │ ├── java/
│ │ │ │ │ └── com/
│ │ │ │ │ └── didispace/
│ │ │ │ │ ├── Application.java
│ │ │ │ │ └── service/
│ │ │ │ │ ├── ComputeService.java
│ │ │ │ │ └── impl/
│ │ │ │ │ └── ComputeServiceImpl.java
│ │ │ │ └── resources/
│ │ │ │ ├── application.properties
│ │ │ │ └── dubbo.xml
│ │ │ └── test/
│ │ │ └── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── ApplicationTests.java
│ │ └── consumer/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ ├── Application.java
│ │ │ │ └── service/
│ │ │ │ └── ComputeService.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── dubbo.xml
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── Chapter9-2-2/
│ │ ├── compute-service/
│ │ │ ├── compute-api/
│ │ │ │ ├── pom.xml
│ │ │ │ └── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── service/
│ │ │ │ ├── ComputeService.java
│ │ │ │ └── impl/
│ │ │ │ └── ComputeServiceImpl.java
│ │ │ ├── compute-api-server/
│ │ │ │ ├── pom.xml
│ │ │ │ └── src/
│ │ │ │ ├── main/
│ │ │ │ │ ├── java/
│ │ │ │ │ │ └── com/
│ │ │ │ │ │ └── didispace/
│ │ │ │ │ │ ├── Application.java
│ │ │ │ │ │ └── service/
│ │ │ │ │ │ └── impl/
│ │ │ │ │ │ └── ComputeServiceImpl.java
│ │ │ │ │ └── resources/
│ │ │ │ │ ├── application.properties
│ │ │ │ │ └── dubbo.xml
│ │ │ │ └── test/
│ │ │ │ └── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── ApplicationTests.java
│ │ │ └── pom.xml
│ │ └── consumer/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── Application.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── dubbo.xml
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── ApplicationTests.java
│ ├── README.md
│ └── README_zh.md
├── 2.x/
│ ├── README.md
│ ├── README_zh.md
│ ├── chapter1-1/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter11/
│ │ │ │ ├── Chapter11Application.java
│ │ │ │ └── HelloController.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter11/
│ │ └── Chapter11ApplicationTests.java
│ ├── chapter1-2/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter12/
│ │ │ └── Chapter12Application.java
│ │ └── resources/
│ │ └── application.yaml
│ ├── chapter1-3/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter13/
│ │ │ └── Chapter13Application.java
│ │ └── resources/
│ │ └── application.yaml
│ ├── chapter1-4/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter14/
│ │ │ ├── Chapter14Application.java
│ │ │ ├── DidiProperties.java
│ │ │ └── HelloController.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter1-5/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter15/
│ │ │ │ └── Chapter15Application.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter15/
│ │ └── PropertiesTest.java
│ ├── chapter2-1/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter21/
│ │ │ │ ├── Chapter21Application.java
│ │ │ │ ├── User.java
│ │ │ │ └── UserController.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter21/
│ │ └── Chapter21ApplicationTests.java
│ ├── chapter2-2/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter22/
│ │ │ ├── Chapter22Application.java
│ │ │ ├── User.java
│ │ │ └── UserController.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter2-3/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter23/
│ │ │ ├── Chapter23Application.java
│ │ │ ├── User.java
│ │ │ └── UserController.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter2-4/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter24/
│ │ │ ├── Chapter24Application.java
│ │ │ ├── User.java
│ │ │ └── UserController.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter2-5/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── docs/
│ │ │ ├── asciidoc/
│ │ │ │ ├── generated/
│ │ │ │ │ ├── definitions.adoc
│ │ │ │ │ ├── overview.adoc
│ │ │ │ │ ├── paths.adoc
│ │ │ │ │ └── security.adoc
│ │ │ │ ├── generated-by-plugin/
│ │ │ │ │ ├── definitions.adoc
│ │ │ │ │ ├── overview.adoc
│ │ │ │ │ ├── paths.adoc
│ │ │ │ │ └── security.adoc
│ │ │ │ └── html/
│ │ │ │ ├── definitions.html
│ │ │ │ ├── overview.html
│ │ │ │ ├── paths.html
│ │ │ │ └── security.html
│ │ │ ├── confluence/
│ │ │ │ └── generated/
│ │ │ │ ├── definitions.txt
│ │ │ │ ├── overview.txt
│ │ │ │ ├── paths.txt
│ │ │ │ └── security.txt
│ │ │ └── markdown/
│ │ │ └── generated/
│ │ │ ├── definitions.md
│ │ │ ├── overview.md
│ │ │ ├── paths.md
│ │ │ └── security.md
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter25/
│ │ │ │ ├── Chapter25Application.java
│ │ │ │ ├── User.java
│ │ │ │ └── UserController.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter25/
│ │ └── DemoApplicationTests.java
│ ├── chapter2-6/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter26/
│ │ │ ├── Chapter26Application.java
│ │ │ ├── User.java
│ │ │ └── UserController.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter2-7/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter27/
│ │ │ ├── Chapter27Application.java
│ │ │ ├── User.java
│ │ │ └── UserController.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter2-8/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter28/
│ │ │ ├── Chapter28Application.java
│ │ │ ├── User.java
│ │ │ └── UserController.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter2-9/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter29/
│ │ │ ├── Chapter29Application.java
│ │ │ ├── User.java
│ │ │ └── UserController.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter3-1/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter31/
│ │ │ │ ├── Chapter31Application.java
│ │ │ │ ├── User.java
│ │ │ │ ├── UserService.java
│ │ │ │ └── UserServiceImpl.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter31/
│ │ └── Chapter31ApplicationTests.java
│ ├── chapter3-10/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter310/
│ │ │ │ ├── Chapter310Application.java
│ │ │ │ ├── User.java
│ │ │ │ └── UserRepository.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter310/
│ │ └── Chapter310ApplicationTests.java
│ ├── chapter3-11/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter311/
│ │ │ │ ├── Chapter311Application.java
│ │ │ │ ├── User.java
│ │ │ │ ├── UserService.java
│ │ │ │ └── UserServiceImpl.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── db/
│ │ │ └── migration/
│ │ │ ├── V1_1__alter_table_user.sql
│ │ │ └── V1__Base_version.sql
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter311/
│ │ └── Chapter311ApplicationTests.java
│ ├── chapter3-12/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter312/
│ │ │ │ ├── Chapter312Application.java
│ │ │ │ ├── DataSourceConfiguration.java
│ │ │ │ └── TestService.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter312/
│ │ └── Chapter312ApplicationTests.java
│ ├── chapter3-13/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter313/
│ │ │ │ └── Chapter313Application.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── schema-all.sql
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter31/
│ │ └── Chapter31ApplicationTests.java
│ ├── chapter3-2/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter32/
│ │ │ │ ├── Chapter32Application.java
│ │ │ │ ├── User.java
│ │ │ │ ├── UserService.java
│ │ │ │ └── UserServiceImpl.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter32/
│ │ └── Chapter32ApplicationTests.java
│ ├── chapter3-3/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter33/
│ │ │ │ ├── Chapter33Application.java
│ │ │ │ ├── User.java
│ │ │ │ ├── UserController.java
│ │ │ │ ├── UserService.java
│ │ │ │ └── UserServiceImpl.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter33/
│ │ └── Chapter33ApplicationTests.java
│ ├── chapter3-4/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter34/
│ │ │ │ ├── Chapter34Application.java
│ │ │ │ ├── User.java
│ │ │ │ └── UserRepository.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter34/
│ │ └── Chapter34ApplicationTests.java
│ ├── chapter3-5/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter35/
│ │ │ │ ├── Chapter35Application.java
│ │ │ │ ├── User.java
│ │ │ │ └── UserMapper.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter35/
│ │ └── Chapter35ApplicationTests.java
│ ├── chapter3-6/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter36/
│ │ │ │ ├── Chapter36Application.java
│ │ │ │ ├── entity/
│ │ │ │ │ └── User.java
│ │ │ │ └── mapper/
│ │ │ │ └── UserMapper.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── mapper/
│ │ │ └── UserMapper.xml
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter36/
│ │ └── Chapter36ApplicationTests.java
│ ├── chapter3-7/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter37/
│ │ │ │ ├── Chapter37Application.java
│ │ │ │ └── DataSourceConfiguration.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter37/
│ │ └── Chapter37ApplicationTests.java
│ ├── chapter3-8/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter38/
│ │ │ │ ├── Chapter38Application.java
│ │ │ │ ├── DataSourceConfiguration.java
│ │ │ │ ├── PrimaryConfig.java
│ │ │ │ ├── SecondaryConfig.java
│ │ │ │ ├── p/
│ │ │ │ │ ├── User.java
│ │ │ │ │ └── UserRepository.java
│ │ │ │ └── s/
│ │ │ │ ├── Message.java
│ │ │ │ └── MessageRepository.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter38/
│ │ └── Chapter38ApplicationTests.java
│ ├── chapter3-9/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter39/
│ │ │ │ ├── Chapter39Application.java
│ │ │ │ ├── DataSourceConfiguration.java
│ │ │ │ ├── PrimaryConfig.java
│ │ │ │ ├── SecondaryConfig.java
│ │ │ │ ├── p/
│ │ │ │ │ ├── entity/
│ │ │ │ │ │ └── UserPrimary.java
│ │ │ │ │ └── mapper/
│ │ │ │ │ └── UserMapperPrimary.java
│ │ │ │ └── s/
│ │ │ │ ├── entity/
│ │ │ │ │ └── UserSecondary.java
│ │ │ │ └── mapper/
│ │ │ │ └── UserMapperSecondary.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ ├── mapper.primary/
│ │ │ │ └── UserMapper.xml
│ │ │ └── mapper.secondary/
│ │ │ └── UserMapper.xml
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter39/
│ │ └── Chapter39ApplicationTests.java
│ ├── chapter4-1/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter41/
│ │ │ ├── Chapter41Application.java
│ │ │ └── HelloController.java
│ │ └── resources/
│ │ ├── application.properties
│ │ └── templates/
│ │ └── index.html
│ ├── chapter4-2/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter42/
│ │ │ ├── Chapter42Application.java
│ │ │ └── HelloController.java
│ │ └── resources/
│ │ ├── application.properties
│ │ └── templates/
│ │ └── index.html
│ ├── chapter4-3/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter43/
│ │ │ │ ├── Chapter43Application.java
│ │ │ │ └── UploadController.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── templates/
│ │ │ └── upload.html
│ │ └── test/
│ │ └── java/
│ │ └── FileTest.java
│ ├── chapter4-4/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter44/
│ │ │ │ ├── Chapter44Application.java
│ │ │ │ └── UploadController.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── templates/
│ │ │ └── upload.html
│ │ └── test/
│ │ └── java/
│ │ └── FileTest.java
│ ├── chapter4-5/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter45/
│ │ │ ├── Application.java
│ │ │ ├── HelloController.java
│ │ │ └── WebSecurityConfig.java
│ │ └── resources/
│ │ ├── application.properties
│ │ └── templates/
│ │ ├── hello.html
│ │ ├── index.html
│ │ └── login.html
│ ├── chapter5-1/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter51/
│ │ │ │ ├── Chapter51Application.java
│ │ │ │ ├── User.java
│ │ │ │ └── UserRepository.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter51/
│ │ └── Chapter51ApplicationTests.java
│ ├── chapter5-2/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter52/
│ │ │ │ ├── Chapter52Application.java
│ │ │ │ ├── User.java
│ │ │ │ └── UserRepository.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ └── ehcache.xml
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter52/
│ │ └── Chapter52ApplicationTests.java
│ ├── chapter5-3/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter53/
│ │ │ │ ├── Chapter53Application.java
│ │ │ │ ├── User.java
│ │ │ │ └── UserRepository.java
│ │ │ └── resources/
│ │ │ ├── application.properties
│ │ │ ├── ehcache-1.xml
│ │ │ └── ehcache-2.xml
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter53/
│ │ └── Chapter53ApplicationTests.java
│ ├── chapter5-4/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter54/
│ │ │ │ ├── Chapter54Application.java
│ │ │ │ ├── User.java
│ │ │ │ └── UserRepository.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter54/
│ │ └── Chapter54ApplicationTests.java
│ ├── chapter5-5/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter55/
│ │ │ └── Chapter55Application.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter6-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter61/
│ │ │ │ ├── Chapter61Application.java
│ │ │ │ ├── User.java
│ │ │ │ └── UserRepository.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter61/
│ │ └── ApplicationTests.java
│ ├── chapter6-2/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter62/
│ │ │ │ ├── Chapter62Application.java
│ │ │ │ ├── Person.java
│ │ │ │ └── PersonRepository.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter62/
│ │ │ └── ApplicationTests.java
│ │ └── resources/
│ │ ├── application.properties
│ │ └── ldap-server.ldif
│ ├── chapter6-3/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter63/
│ │ │ │ ├── Chapter63Application.java
│ │ │ │ └── Monitor.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter63/
│ │ └── ApplicationTests.java
│ ├── chapter6-4/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter64/
│ │ │ │ ├── Chapter64Application.java
│ │ │ │ ├── UserInfo.java
│ │ │ │ └── UserInfoRepository.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter64/
│ │ └── ApplicationTests.java
│ ├── chapter7-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter71/
│ │ │ ├── Chapter71Application.java
│ │ │ └── ScheduledTasks.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter7-2/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter72/
│ │ │ ├── Chapter72Application.java
│ │ │ └── MySimpleJob.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter7-3/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter73/
│ │ │ ├── Chapter73Application.java
│ │ │ └── MyShardingJob.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter7-4/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter74/
│ │ │ ├── Chapter74Application.java
│ │ │ └── MySimpleJob.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter7-5/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter75/
│ │ │ │ ├── AsyncTasks.java
│ │ │ │ └── Chapter75Application.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter75/
│ │ └── Chapter75ApplicationTests.java
│ ├── chapter7-6/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter76/
│ │ │ │ ├── AsyncTasks.java
│ │ │ │ └── Chapter76Application.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter76/
│ │ └── Chapter76ApplicationTests.java
│ ├── chapter7-7/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter77/
│ │ │ │ ├── AsyncTasks.java
│ │ │ │ └── Chapter77Application.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter77/
│ │ └── Chapter77ApplicationTests.java
│ ├── chapter7-8/
│ │ ├── pom.xml
│ │ └── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── didispace/
│ │ │ │ └── chapter78/
│ │ │ │ ├── AsyncTasks.java
│ │ │ │ └── Chapter78Application.java
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/
│ │ └── java/
│ │ └── com/
│ │ └── didispace/
│ │ └── chapter78/
│ │ └── Chapter78ApplicationTests.java
│ ├── chapter8-1/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter81/
│ │ │ └── Chapter81Application.java
│ │ └── resources/
│ │ └── application.properties
│ ├── chapter8-2/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter82/
│ │ │ └── Chapter82Application.java
│ │ └── resources/
│ │ ├── application.properties
│ │ └── log4j2.xml
│ ├── chapter8-3/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── didispace/
│ │ │ └── chapter83/
│ │ │ └── Chapter83Application.java
│ │ └── resources/
│ │ ├── application.properties
│ │ └── tinylog.properties
│ └── pom.xml
├── README.md
├── README_zh.md
└── pom.xml
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.class
.classpath
.project
build
bin
.bak
.settings
Thumbs.db
.DS_Store
._.DS_Store
logs
target
*.iml
.idea
================================================
FILE: .gitmodules
================================================
================================================
FILE: 1.x/Chapter1/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter1</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter1</name>
<description>The first Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter1/src/main/java/com/didispace/Chapter1Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Chapter1Application {
public static void main(String[] args) {
SpringApplication.run(Chapter1Application.class, args);
}
}
================================================
FILE: 1.x/Chapter1/src/main/java/com/didispace/web/HelloController.java
================================================
package com.didispace.web;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String index() {
return "Hello World";
}
}
================================================
FILE: 1.x/Chapter1/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter1/src/test/java/com/didispace/Chapter1ApplicationTests.java
================================================
package com.didispace;
import com.didispace.web.HelloController;
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 Chapter1ApplicationTests {
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(status().isOk())
.andExpect(content().string(equalTo("Hello World")));
}
}
================================================
FILE: 1.x/Chapter2-1-1/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter2-1-1</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter2-1-1</name>
<description></description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter2-1-1/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter2-1-1/src/main/java/com/didispace/service/BlogProperties.java
================================================
package com.didispace.service;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/5/5 下午12:16.
* @blog http://blog.didispace.com
*/
@Component
public class BlogProperties {
@Value("${com.didispace.blog.name}")
private String name;
@Value("${com.didispace.blog.title}")
private String title;
@Value("${com.didispace.blog.desc}")
private String desc;
@Value("${com.didispace.blog.value}")
private String value;
@Value("${com.didispace.blog.number}")
private Integer number;
@Value("${com.didispace.blog.bignumber}")
private Long bignumber;
@Value("${com.didispace.blog.test1}")
private Integer test1;
@Value("${com.didispace.blog.test2}")
private Integer test2;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public Integer getNumber() {
return number;
}
public void setNumber(Integer number) {
this.number = number;
}
public Long getBignumber() {
return bignumber;
}
public void setBignumber(Long bignumber) {
this.bignumber = bignumber;
}
public Integer getTest1() {
return test1;
}
public void setTest1(Integer test1) {
this.test1 = test1;
}
public Integer getTest2() {
return test2;
}
public void setTest2(Integer test2) {
this.test2 = test2;
}
}
================================================
FILE: 1.x/Chapter2-1-1/src/main/java/com/didispace/web/HelloController.java
================================================
package com.didispace.web;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@RestController
public class HelloController {
@RequestMapping("/hello")
public String index() {
return "Hello World";
}
}
================================================
FILE: 1.x/Chapter2-1-1/src/main/resources/application-dev.properties
================================================
# 服务端口
server.port=1111
================================================
FILE: 1.x/Chapter2-1-1/src/main/resources/application-prod.properties
================================================
# 服务端口
server.port=3333
================================================
FILE: 1.x/Chapter2-1-1/src/main/resources/application-test.properties
================================================
# 服务端口
server.port=2222
================================================
FILE: 1.x/Chapter2-1-1/src/main/resources/application.properties
================================================
com.didispace.blog.name=程序猿DD
com.didispace.blog.title=Spring Boot教程
com.didispace.blog.desc=${com.didispace.blog.name}正在努力写《${com.didispace.blog.title}》
# 随机字符串
com.didispace.blog.value=${random.value}
# 随机int
com.didispace.blog.number=${random.int}
# 随机long
com.didispace.blog.bignumber=${random.long}
# 10以内的随机数
com.didispace.blog.test1=${random.int(10)}
# 10-20的随机数
com.didispace.blog.test2=${random.int[10,20]}
# 多环境配置文件激活属性
spring.profiles.active=dev
================================================
FILE: 1.x/Chapter2-1-1/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.service.BlogProperties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.mock.web.MockServletContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class)
public class ApplicationTests {
private static final Log log = LogFactory.getLog(ApplicationTests.class);
@Autowired
private BlogProperties blogProperties;
@Test
public void test1() throws Exception {
Assert.assertEquals("程序猿DD", blogProperties.getName());
Assert.assertEquals("Spring Boot教程", blogProperties.getTitle());
Assert.assertEquals("程序猿DD正在努力写《Spring Boot教程》", blogProperties.getDesc());
log.info("随机数测试输出:");
log.info("随机字符串 : " + blogProperties.getValue());
log.info("随机int : " + blogProperties.getNumber());
log.info("随机long : " + blogProperties.getBignumber());
log.info("随机10以下 : " + blogProperties.getTest1());
log.info("随机10-20 : " + blogProperties.getTest2());
}
}
================================================
FILE: 1.x/Chapter2-1-2/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter2-1-2</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter2-1-2</name>
<description>Spring Boot 2.0 features : Application Events and Listeners</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@Slf4j
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public DataLoader dataLoader() {
return new DataLoader();
}
@Slf4j
static class DataLoader implements CommandLineRunner {
@Override
public void run(String... strings) throws Exception {
log.info("Loading data...");
}
}
}
================================================
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationEnvironmentPreparedEventListener.java
================================================
package com.didispace;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.context.ApplicationListener;
@Slf4j
public class ApplicationEnvironmentPreparedEventListener implements ApplicationListener<ApplicationEnvironmentPreparedEvent> {
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
log.info("......ApplicationEnvironmentPreparedEvent......");
}
}
================================================
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationFailedEventListener.java
================================================
package com.didispace;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.context.ApplicationListener;
@Slf4j
public class ApplicationFailedEventListener implements ApplicationListener<ApplicationFailedEvent> {
@Override
public void onApplicationEvent(ApplicationFailedEvent event) {
log.info("......ApplicationFailedEvent......");
}
}
================================================
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationPreparedEventListener.java
================================================
package com.didispace;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.context.ApplicationListener;
@Slf4j
public class ApplicationPreparedEventListener implements ApplicationListener<ApplicationPreparedEvent> {
@Override
public void onApplicationEvent(ApplicationPreparedEvent event) {
log.info("......ApplicationPreparedEvent......");
}
}
================================================
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationReadyEventListener.java
================================================
package com.didispace;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
@Slf4j
public class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent> {
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
log.info("......ApplicationReadyEvent......");
}
}
================================================
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationStartedEventListener.java
================================================
package com.didispace;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
@Slf4j
public class ApplicationStartedEventListener implements ApplicationListener<ApplicationStartedEvent> {
@Override
public void onApplicationEvent(ApplicationStartedEvent event) {
log.info("......ApplicationStartedEvent......");
}
}
================================================
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationStartingEventListener.java
================================================
package com.didispace;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationStartingEvent;
import org.springframework.context.ApplicationListener;
@Slf4j
public class ApplicationStartingEventListener implements ApplicationListener<ApplicationStartingEvent> {
@Override
public void onApplicationEvent(ApplicationStartingEvent event) {
log.info("......ApplicationStartingEvent......");
}
}
================================================
FILE: 1.x/Chapter2-1-2/src/main/resources/META-INF/spring.factories
================================================
org.springframework.context.ApplicationListener=com.didispace.ApplicationEnvironmentPreparedEventListener,\
com.didispace.ApplicationFailedEventListener,\
com.didispace.ApplicationPreparedEventListener,\
com.didispace.ApplicationReadyEventListener,\
com.didispace.ApplicationStartedEventListener,\
com.didispace.ApplicationStartingEventListener
================================================
FILE: 1.x/Chapter2-1-2/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter2-2-1/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter2-2-1</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter2-2-1</name>
<description>Spring Boot 2 : Relaxed Binding</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter2-2-1/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.context.ApplicationContext;
import java.util.List;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@SpringBootApplication
public class Application {
public static void main(String[] args) {
ApplicationContext context = SpringApplication.run(Application.class, args);
Binder binder = Binder.get(context.getEnvironment());
// 绑定简单配置
FooProperties foo = binder.bind("com.didispace", Bindable.of(FooProperties.class)).get();
System.out.println(foo.getFoo());
// 绑定List配置
List<String> post = binder.bind("com.didispace.post", Bindable.listOf(String.class)).get();
System.out.println(post);
List<PostInfo> posts = binder.bind("com.didispace.posts", Bindable.listOf(PostInfo.class)).get();
System.out.println(posts);
// 读取配置
System.out.println(context.getEnvironment().containsProperty("com.didispace.database-platform"));
System.out.println(context.getEnvironment().containsProperty("com.didispace.databasePlatform"));
}
}
================================================
FILE: 1.x/Chapter2-2-1/src/main/java/com/didispace/FooProperties.java
================================================
package com.didispace;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
@Data
@ConfigurationProperties(prefix = "com.didispace")
public class FooProperties {
private String foo;
private String databasePlatform;
}
================================================
FILE: 1.x/Chapter2-2-1/src/main/java/com/didispace/PostInfo.java
================================================
package com.didispace;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
@Data
@ConfigurationProperties
public class PostInfo {
private String title;
private String content;
}
================================================
FILE: 1.x/Chapter2-2-1/src/main/resources/application.properties
================================================
com.didispace.foo=bar
com.didispace.database-platform=sql
com.didispace.post[0]=Why Spring Boot
com.didispace.post[1]=Why Spring Cloud
com.didispace.posts[0].title=Why Spring Boot
com.didispace.posts[0].content=It is perfect!
com.didispace.posts[1].title=Why Spring Cloud
com.didispace.posts[1].content=It is perfect too!
================================================
FILE: 1.x/Chapter3-1-1/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-1-1</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-1-1</name>
<description>RESTful API Project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-1-1/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter3-1-1/src/main/java/com/didispace/domain/User.java
================================================
package com.didispace.domain;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
public class User {
private Long id;
private String name;
private Integer age;
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 Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
================================================
FILE: 1.x/Chapter3-1-1/src/main/java/com/didispace/web/HelloController.java
================================================
package com.didispace.web;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@RestController
public class HelloController {
@RequestMapping("/hello")
public String index() {
return "Hello World";
}
}
================================================
FILE: 1.x/Chapter3-1-1/src/main/java/com/didispace/web/UserController.java
================================================
package com.didispace.web;
import com.didispace.domain.User;
import java.util.*;
import org.springframework.web.bind.annotation.*;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@RestController
@RequestMapping(value="/users") // 通过这里配置使下面的映射都在/users下,可去除
public class UserController {
static Map<Long, User> users = Collections.synchronizedMap(new HashMap<Long, User>());
@RequestMapping(value="/", method=RequestMethod.GET)
public List<User> getUserList() {
// 处理"/users/"的GET请求,用来获取用户列表
// 还可以通过@RequestParam从页面中传递参数来进行查询条件或者翻页信息的传递
List<User> r = new ArrayList<User>(users.values());
return r;
}
@RequestMapping(value="/", method=RequestMethod.POST)
public String postUser(@ModelAttribute User user) {
// 处理"/users/"的POST请求,用来创建User
// 除了@ModelAttribute绑定参数之外,还可以通过@RequestParam从页面中传递参数
users.put(user.getId(), user);
return "success";
}
@RequestMapping(value="/{id}", method=RequestMethod.GET)
public User getUser(@PathVariable Long id) {
// 处理"/users/{id}"的GET请求,用来获取url中id值的User信息
// url中的id可通过@PathVariable绑定到函数的参数中
return users.get(id);
}
@RequestMapping(value="/{id}", method=RequestMethod.PUT)
public String putUser(@PathVariable Long id, @ModelAttribute User user) {
// 处理"/users/{id}"的PUT请求,用来更新User信息
User u = users.get(id);
u.setName(user.getName());
u.setAge(user.getAge());
users.put(id, u);
return "success";
}
@RequestMapping(value="/{id}", method=RequestMethod.DELETE)
public String deleteUser(@PathVariable Long id) {
// 处理"/users/{id}"的DELETE请求,用来删除User
users.remove(id);
return "success";
}
}
================================================
FILE: 1.x/Chapter3-1-1/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter3-1-1/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.domain.User;
import com.didispace.web.HelloController;
import com.didispace.web.UserController;
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.RequestBuilder;
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.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MockServletContext.class)
@WebAppConfiguration
public class ApplicationTests {
private MockMvc mvc;
@Before
public void setUp() throws Exception {
mvc = MockMvcBuilders.standaloneSetup(
new HelloController(),
new UserController()).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")));
}
@Test
public void testUserController() throws Exception {
// 测试UserController
RequestBuilder request = null;
// 1、get查一下user列表,应该为空
request = get("/users/");
mvc.perform(request)
.andExpect(status().isOk())
.andExpect(content().string(equalTo("[]")));
// 2、post提交一个user
request = post("/users/")
.param("id", "1")
.param("name", "测试大师")
.param("age", "20");
mvc.perform(request)
// .andDo(MockMvcResultHandlers.print())
.andExpect(content().string(equalTo("success")));
// 3、get获取user列表,应该有刚才插入的数据
request = get("/users/");
mvc.perform(request)
.andExpect(status().isOk())
.andExpect(content().string(equalTo("[{\"id\":1,\"name\":\"测试大师\",\"age\":20}]")));
// 4、put修改id为1的user
request = put("/users/1")
.param("name", "测试终极大师")
.param("age", "30");
mvc.perform(request)
.andExpect(content().string(equalTo("success")));
// 5、get一个id为1的user
request = get("/users/1");
mvc.perform(request)
.andExpect(content().string(equalTo("{\"id\":1,\"name\":\"测试终极大师\",\"age\":30}")));
// 6、del删除id为1的user
request = delete("/users/1");
mvc.perform(request)
.andExpect(content().string(equalTo("success")));
// 7、get查一下user列表,应该为空
request = get("/users/");
mvc.perform(request)
.andExpect(status().isOk())
.andExpect(content().string(equalTo("[]")));
}
}
================================================
FILE: 1.x/Chapter3-1-2/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-1-2</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-1-2</name>
<description>Spring Boot with Thymeleaf</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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-thymeleaf</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>
================================================
FILE: 1.x/Chapter3-1-2/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter3-1-2/src/main/java/com/didispace/web/HelloController.java
================================================
package com.didispace.web;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@Controller
public class HelloController {
@ResponseBody
@RequestMapping("/hello")
public String hello() {
return "Hello World";
}
@RequestMapping("/")
public String index(ModelMap map) {
map.addAttribute("host", "http://blog.didispace.com");
return "index";
}
}
================================================
FILE: 1.x/Chapter3-1-2/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter3-1-2/src/main/resources/templates/index.html
================================================
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<h1 th:text="${host}">Hello World</h1>
</body>
</html>
================================================
FILE: 1.x/Chapter3-1-2/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.web.HelloController;
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;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MockServletContext.class)
@WebAppConfiguration
public class ApplicationTests {
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(status().isOk())
.andExpect(content().string(equalTo("Hello World")));
}
}
================================================
FILE: 1.x/Chapter3-1-3/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>demo</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Spring Boot Web project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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-freemarker</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>
================================================
FILE: 1.x/Chapter3-1-3/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter3-1-3/src/main/java/com/didispace/web/HelloController.java
================================================
package com.didispace.web;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@Controller
public class HelloController {
@RequestMapping("/hello")
@ResponseBody
public String hello() {
return "Hello World";
}
@RequestMapping("/")
public String index(ModelMap map) {
map.addAttribute("host", "http://blog.didispace.com");
return "index";
}
}
================================================
FILE: 1.x/Chapter3-1-3/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter3-1-3/src/main/resources/templates/index.ftl
================================================
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8" />
<title></title>
</head>
<body>
FreeMarker模板引擎
<h1>${host}</h1>
</body>
</html>
================================================
FILE: 1.x/Chapter3-1-3/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.web.HelloController;
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;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MockServletContext.class)
@WebAppConfiguration
public class ApplicationTests {
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(status().isOk())
.andExpect(content().string(equalTo("Hello World")));
}
}
================================================
FILE: 1.x/Chapter3-1-4/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>demo</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Spring Boot Web project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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-velocity</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>
================================================
FILE: 1.x/Chapter3-1-4/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter3-1-4/src/main/java/com/didispace/web/HelloController.java
================================================
package com.didispace.web;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@Controller
public class HelloController {
@RequestMapping("/hello")
@ResponseBody
public String hello() {
return "Hello World";
}
@RequestMapping("/")
public String index(ModelMap map) {
map.addAttribute("host", "http://blog.didispace.com");
return "index";
}
}
================================================
FILE: 1.x/Chapter3-1-4/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter3-1-4/src/main/resources/templates/index.vm
================================================
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8" />
<title></title>
</head>
<body>
Velocity模板
<h1>${host}</h1>
</body>
</html>
================================================
FILE: 1.x/Chapter3-1-4/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.web.HelloController;
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;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MockServletContext.class)
@WebAppConfiguration
public class ApplicationTests {
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(status().isOk())
.andExpect(content().string(equalTo("Hello World")));
}
}
================================================
FILE: 1.x/Chapter3-1-5/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>SpringBootWithSwagger</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>SpringBootWithSwagger</name>
<description>SpringBootWithSwagger</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.2.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-1-5/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter3-1-5/src/main/java/com/didispace/Swagger2.java
================================================
package com.didispace;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/4/18 下午12:02.
* @blog http://blog.didispace.com
*/
@Configuration
@EnableSwagger2
public class Swagger2 {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.didispace.web"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Spring Boot中使用Swagger2构建RESTful APIs")
.description("更多Spring Boot相关文章请关注:http://blog.didispace.com/")
.termsOfServiceUrl("http://blog.didispace.com/")
.contact("程序猿DD")
.version("1.0")
.build();
}
}
================================================
FILE: 1.x/Chapter3-1-5/src/main/java/com/didispace/domain/User.java
================================================
package com.didispace.domain;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
public class User {
private Long id;
private String name;
private Integer age;
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 Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
================================================
FILE: 1.x/Chapter3-1-5/src/main/java/com/didispace/web/HelloController.java
================================================
package com.didispace.web;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@RestController
public class HelloController {
@ApiIgnore
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public String index() {
return "Hello World";
}
}
================================================
FILE: 1.x/Chapter3-1-5/src/main/java/com/didispace/web/UserController.java
================================================
package com.didispace.web;
import com.didispace.domain.User;
import java.util.*;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@RestController
@RequestMapping(value="/users") // 通过这里配置使下面的映射都在/users下,可去除
public class UserController {
static Map<Long, User> users = Collections.synchronizedMap(new HashMap<Long, User>());
@ApiOperation(value="获取用户列表", notes="")
@RequestMapping(value={""}, method=RequestMethod.GET)
public List<User> getUserList() {
List<User> r = new ArrayList<User>(users.values());
return r;
}
@ApiOperation(value="创建用户", notes="根据User对象创建用户")
@ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "User")
@RequestMapping(value="", method=RequestMethod.POST)
public String postUser(@RequestBody User user) {
users.put(user.getId(), user);
return "success";
}
@ApiOperation(value="获取用户详细信息", notes="根据url的id来获取用户详细信息")
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long", paramType = "path")
@RequestMapping(value="/{id}", method=RequestMethod.GET)
public User getUser(@PathVariable Long id) {
return users.get(id);
}
@ApiOperation(value="更新用户详细信息", notes="根据url的id来指定更新对象,并根据传过来的user信息来更新用户详细信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long", paramType = "path"),
@ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "User")
})
@RequestMapping(value="/{id}", method=RequestMethod.PUT)
public String putUser(@PathVariable Long id, @RequestBody User user) {
User u = users.get(id);
u.setName(user.getName());
u.setAge(user.getAge());
users.put(id, u);
return "success";
}
@ApiOperation(value="删除用户", notes="根据url的id来指定删除对象")
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long", paramType = "path")
@RequestMapping(value="/{id}", method=RequestMethod.DELETE)
public String deleteUser(@PathVariable Long id) {
users.remove(id);
return "success";
}
}
================================================
FILE: 1.x/Chapter3-1-5/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter3-1-6/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-1-6</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-1-6</name>
<description>Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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-thymeleaf</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>
================================================
FILE: 1.x/Chapter3-1-6/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter3-1-6/src/main/java/com/didispace/dto/ErrorInfo.java
================================================
package com.didispace.dto;
public class ErrorInfo<T> {
public static final Integer OK = 0;
public static final Integer ERROR = 100;
private Integer code;
private String message;
private String url;
private T data;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public static Integer getOK() {
return OK;
}
public static Integer getERROR() {
return ERROR;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
================================================
FILE: 1.x/Chapter3-1-6/src/main/java/com/didispace/exception/GlobalExceptionHandler.java
================================================
package com.didispace.exception;
import com.didispace.dto.ErrorInfo;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(value = Exception.class)
public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) throws Exception {
ModelAndView mav = new ModelAndView();
mav.addObject("exception", e);
mav.addObject("url", req.getRequestURL());
mav.setViewName("error");
return mav;
}
@ExceptionHandler(value = MyException.class)
@ResponseBody
public ErrorInfo<String> jsonErrorHandler(HttpServletRequest req, MyException e) throws Exception {
ErrorInfo<String> r = new ErrorInfo<>();
r.setMessage(e.getMessage());
r.setCode(ErrorInfo.ERROR);
r.setData("Some Data");
r.setUrl(req.getRequestURL().toString());
return r;
}
}
================================================
FILE: 1.x/Chapter3-1-6/src/main/java/com/didispace/exception/MyException.java
================================================
package com.didispace.exception;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/5/2 上午10:50.
* @blog http://blog.didispace.com
*/
public class MyException extends Exception {
public MyException(String message) {
super(message);
}
}
================================================
FILE: 1.x/Chapter3-1-6/src/main/java/com/didispace/web/HelloController.java
================================================
package com.didispace.web;
import com.didispace.exception.MyException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@Controller
public class HelloController {
@RequestMapping("/hello")
public String hello() throws Exception {
throw new Exception("发生错误");
}
@RequestMapping("/json")
public String json() throws MyException {
throw new MyException("发生错误2");
}
@RequestMapping("/")
public String index(ModelMap map) {
map.addAttribute("host", "http://blog.didispace.com");
return "index";
}
}
================================================
FILE: 1.x/Chapter3-1-6/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter3-1-6/src/main/resources/templates/error.html
================================================
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8" />
<title>统一异常处理</title>
</head>
<body>
<h1>Error Handler</h1>
<div th:text="${url}"></div>
<div th:text="${exception.message}"></div>
</body>
</html>
================================================
FILE: 1.x/Chapter3-1-6/src/main/resources/templates/index.html
================================================
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<h1 th:text="${host}">Hello World</h1>
</body>
</html>
================================================
FILE: 1.x/Chapter3-1-6/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.web.HelloController;
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;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MockServletContext.class)
@WebAppConfiguration
public class ApplicationTests {
}
================================================
FILE: 1.x/Chapter3-1-7/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-1-7</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-1-7</name>
<description>Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<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>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
</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>
================================================
FILE: 1.x/Chapter3-1-7/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
/**
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*/
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@RestController
class HelloController {
@PostMapping("/user")
public UserDto user(@RequestBody UserDto userDto) throws Exception {
return userDto;
}
}
@Data
@NoArgsConstructor
@AllArgsConstructor
static class UserDto {
private String userName;
private LocalDate birthday;
}
@Bean
public ObjectMapper serializingObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.registerModule(new JavaTimeModule());
return objectMapper;
}
}
================================================
FILE: 1.x/Chapter3-1-7/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter3-1-8/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-1-8</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-1-8/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*/
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter3-1-8/src/main/java/com/didispace/web/User.java
================================================
package com.didispace.web;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@JacksonXmlRootElement(localName = "User")
public class User {
@JacksonXmlProperty(localName = "name")
private String name;
@JacksonXmlProperty(localName = "age")
private Integer age;
}
================================================
FILE: 1.x/Chapter3-1-8/src/main/java/com/didispace/web/UserController.java
================================================
package com.didispace.web;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@Controller
public class UserController {
@PostMapping(value = "/user", consumes = MediaType.APPLICATION_XML_VALUE, produces = MediaType.APPLICATION_XML_VALUE)
@ResponseBody
public User create(@RequestBody User user) {
user.setName("didispace.com : " + user.getName());
user.setAge(user.getAge() + 100);
return user;
}
}
================================================
FILE: 1.x/Chapter3-1-8/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter3-2-1/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-2-1</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-2-1</name>
<description>Spring Boot with JDBCTemplate</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-2-1/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
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);
}
}
================================================
FILE: 1.x/Chapter3-2-1/src/main/java/com/didispace/service/UserService.java
================================================
package com.didispace.service;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/17 下午7:04.
* @blog http://blog.didispace.com
*/
public interface UserService {
/**
* 新增一个用户
* @param name
* @param age
*/
void create(String name, Integer age);
/**
* 根据name删除一个用户高
* @param name
*/
void deleteByName(String name);
/**
* 获取用户总量
*/
Integer getAllUsers();
/**
* 删除所有用户
*/
void deleteAllUsers();
}
================================================
FILE: 1.x/Chapter3-2-1/src/main/java/com/didispace/service/UserServiceImpl.java
================================================
package com.didispace.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/17 下午6:44.
* @blog http://blog.didispace.com
*/
@Service
public class UserServiceImpl implements UserService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public void create(String name, Integer age) {
jdbcTemplate.update("insert into USER(NAME, AGE) values(?, ?)", name, age);
}
@Override
public void deleteByName(String name) {
jdbcTemplate.update("delete from USER where NAME = ?", name);
}
@Override
public Integer getAllUsers() {
return jdbcTemplate.queryForObject("select count(1) from USER", Integer.class);
}
@Override
public void deleteAllUsers() {
jdbcTemplate.update("delete from USER");
}
}
================================================
FILE: 1.x/Chapter3-2-1/src/main/resources/application.properties
================================================
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
================================================
FILE: 1.x/Chapter3-2-1/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.service.UserService;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class)
public class ApplicationTests {
@Autowired
private UserService userSerivce;
@Before
public void setUp() {
// 准备,清空user表
userSerivce.deleteAllUsers();
}
@Test
public void test() throws Exception {
// 插入5个用户
userSerivce.create("a", 1);
userSerivce.create("b", 2);
userSerivce.create("c", 3);
userSerivce.create("d", 4);
userSerivce.create("e", 5);
// 查数据库,应该有5个用户
Assert.assertEquals(5, userSerivce.getAllUsers().intValue());
// 删除两个用户
userSerivce.deleteByName("a");
userSerivce.deleteByName("e");
// 查数据库,应该有5个用户
Assert.assertEquals(3, userSerivce.getAllUsers().intValue());
}
}
================================================
FILE: 1.x/Chapter3-2-10/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-2-10</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-2-10</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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-data-ldap</artifactId>
</dependency>
<dependency>
<groupId>com.unboundid</groupId>
<artifactId>unboundid-ldapsdk</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.16</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-2-10/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
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);
}
}
================================================
FILE: 1.x/Chapter3-2-10/src/main/java/com/didispace/Person.java
================================================
package com.didispace;
import lombok.Data;
import org.springframework.ldap.odm.annotations.*;
import javax.naming.Name;
@Entry(base = "ou=people,dc=didispace,dc=com", objectClasses = "inetOrgPerson")
@Data
public class Person {
@Id
private Name id;
@DnAttribute(value = "uid", index = 3)
private String uid;
@Attribute(name = "cn")
private String commonName;
@Attribute(name = "sn")
private String suerName;
private String userPassword;
}
================================================
FILE: 1.x/Chapter3-2-10/src/main/java/com/didispace/PersonRepository.java
================================================
package com.didispace;
import org.springframework.data.repository.CrudRepository;
import javax.naming.Name;
public interface PersonRepository extends CrudRepository<Person, Name> {
}
================================================
FILE: 1.x/Chapter3-2-10/src/main/resources/application.properties
================================================
#spring.ldap.urls=ldap://localhost:1235
#spring.ldap.base=dc=didispace,dc=com
#spring.ldap.username=didispace
#spring.ldap.password=123456
================================================
FILE: 1.x/Chapter3-2-10/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class ApplicationTests {
@Autowired
private PersonRepository personRepository;
@Test
public void findAll() throws Exception {
personRepository.findAll().forEach(p -> {
System.out.println(p);
});
}
@Test
public void save() throws Exception {
Person person = new Person();
person.setUid("uid:1");
person.setSuerName("AAA");
person.setCommonName("aaa");
person.setUserPassword("123456");
personRepository.save(person);
personRepository.findAll().forEach(p -> {
System.out.println(p);
});
}
}
================================================
FILE: 1.x/Chapter3-2-10/src/test/resources/application.properties
================================================
spring.ldap.embedded.ldif=ldap-server.ldif
spring.ldap.embedded.base-dn=dc=didispace,dc=com
================================================
FILE: 1.x/Chapter3-2-10/src/test/resources/ldap-server.ldif
================================================
dn: dc=didispace,dc=com
objectClass: top
objectClass: domain
dn: ou=people,dc=didispace,dc=com
objectclass: top
objectclass: organizationalUnit
ou: people
dn: uid=ben,ou=people,dc=didispace,dc=com
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: didi
sn: zhaiyongchao
uid: didi
userPassword: {SHA}nFCebWjxfaLbHHG1Qk5UU4trbvQ=
================================================
FILE: 1.x/Chapter3-2-11/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-2-11</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-2-11</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>mongodb-plus-spring-boot-starter</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-2-11/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import com.spring4all.mongodb.EnableMongoPlus;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableMongoPlus
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter3-2-11/src/main/resources/application.properties
================================================
spring.data.mongodb.uri=mongodb://localhost:27017/test
spring.data.mongodb.option.min-connection-per-host=20
spring.data.mongodb.option.max-connection-per-host=200
================================================
FILE: 1.x/Chapter3-2-11/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.mongodb.MongoClient;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class ApplicationTests {
@Autowired
private MongoClient mongoClient;
@Test
public void test() throws Exception {
log.info("MinConnectionsPerHost = {}, MaxConnectionsPerHost = {}",
mongoClient.getMongoClientOptions().getMinConnectionsPerHost(),
mongoClient.getMongoClientOptions().getConnectionsPerHost());
}
}
================================================
FILE: 1.x/Chapter3-2-2/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-2-2</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-2-2</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-2-2/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
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);
}
}
================================================
FILE: 1.x/Chapter3-2-2/src/main/java/com/didispace/domain/User.java
================================================
package com.didispace.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/21 下午3:35.
* @blog http://blog.didispace.com
*/
@Entity
public class User {
@Id
@GeneratedValue
private Long id;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private Integer age;
public User(){}
public User(String name, Integer age) {
this.name = name;
this.age = age;
}
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 Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
================================================
FILE: 1.x/Chapter3-2-2/src/main/java/com/didispace/domain/UserRepository.java
================================================
package com.didispace.domain;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/23 下午2:34.
* @blog http://blog.didispace.com
*/
public interface UserRepository extends JpaRepository<User, Long> {
User findByName(String name);
User findByNameAndAge(String name, Integer age);
@Query("from User u where u.name=:name")
User findUser(@Param("name") String name);
}
================================================
FILE: 1.x/Chapter3-2-2/src/main/resources/application.properties
================================================
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=create-drop
================================================
FILE: 1.x/Chapter3-2-2/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.domain.User;
import com.didispace.domain.UserRepository;
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;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class)
public class ApplicationTests {
@Autowired
private UserRepository userRepository;
@Test
public void test() throws Exception {
// 创建10条记录
userRepository.save(new User("AAA", 10));
userRepository.save(new User("BBB", 20));
userRepository.save(new User("CCC", 30));
userRepository.save(new User("DDD", 40));
userRepository.save(new User("EEE", 50));
userRepository.save(new User("FFF", 60));
userRepository.save(new User("GGG", 70));
userRepository.save(new User("HHH", 80));
userRepository.save(new User("III", 90));
userRepository.save(new User("JJJ", 100));
// 测试findAll, 查询所有记录
Assert.assertEquals(10, userRepository.findAll().size());
// 测试findByName, 查询姓名为FFF的User
Assert.assertEquals(60, userRepository.findByName("FFF").getAge().longValue());
// 测试findUser, 查询姓名为FFF的User
Assert.assertEquals(60, userRepository.findUser("FFF").getAge().longValue());
// 测试findByNameAndAge, 查询姓名为FFF并且年龄为60的User
Assert.assertEquals("FFF", userRepository.findByNameAndAge("FFF", 60).getName());
// 测试删除姓名为AAA的User
userRepository.delete(userRepository.findByName("AAA"));
// 测试findAll, 查询所有记录, 验证上面的删除是否成功
Assert.assertEquals(9, userRepository.findAll().size());
}
}
================================================
FILE: 1.x/Chapter3-2-3/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-2-3</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-2-3</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-2-3/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.sql.DataSource;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter3-2-3/src/main/java/com/didispace/DataSourceConfig.java
================================================
package com.didispace;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.sql.DataSource;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/26 下午9:11.
* @blog http://blog.didispace.com
*/
@Configuration
public class DataSourceConfig {
@Bean(name = "primaryDataSource")
@Qualifier("primaryDataSource")
@ConfigurationProperties(prefix="spring.datasource.primary")
public DataSource primaryDataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "secondaryDataSource")
@Qualifier("secondaryDataSource")
@Primary
@ConfigurationProperties(prefix="spring.datasource.secondary")
public DataSource secondaryDataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "primaryJdbcTemplate")
public JdbcTemplate primaryJdbcTemplate(
@Qualifier("primaryDataSource") DataSource dataSource) {
return new JdbcTemplate(dataSource);
}
@Bean(name = "secondaryJdbcTemplate")
public JdbcTemplate secondaryJdbcTemplate(
@Qualifier("secondaryDataSource") DataSource dataSource) {
return new JdbcTemplate(dataSource);
}
}
================================================
FILE: 1.x/Chapter3-2-3/src/main/resources/application.properties
================================================
spring.datasource.primary.url=jdbc:mysql://localhost:3306/test1
spring.datasource.primary.username=root
spring.datasource.primary.password=root
spring.datasource.primary.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.secondary.url=jdbc:mysql://localhost:3306/test2
spring.datasource.secondary.username=root
spring.datasource.secondary.password=root
spring.datasource.secondary.driver-class-name=com.mysql.jdbc.Driver
================================================
FILE: 1.x/Chapter3-2-3/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class)
public class ApplicationTests {
@Autowired
@Qualifier("primaryJdbcTemplate")
protected JdbcTemplate jdbcTemplate1;
@Autowired
@Qualifier("secondaryJdbcTemplate")
protected JdbcTemplate jdbcTemplate2;
@Before
public void setUp() {
jdbcTemplate1.update("DELETE FROM USER ");
jdbcTemplate2.update("DELETE FROM USER ");
}
@Test
public void test() throws Exception {
// 往第一个数据源中插入两条数据
jdbcTemplate1.update("insert into user(id,name,age) values(?, ?, ?)", 1, "aaa", 20);
jdbcTemplate1.update("insert into user(id,name,age) values(?, ?, ?)", 2, "bbb", 30);
// 往第二个数据源中插入一条数据,若插入的是第一个数据源,则会主键冲突报错
jdbcTemplate2.update("insert into user(id,name,age) values(?, ?, ?)", 1, "aaa", 20);
// 查一下第一个数据源中是否有两条数据,验证插入是否成功
Assert.assertEquals("2", jdbcTemplate1.queryForObject("select count(1) from user", String.class));
// 查一下第一个数据源中是否有两条数据,验证插入是否成功
Assert.assertEquals("1", jdbcTemplate2.queryForObject("select count(1) from user", String.class));
}
}
================================================
FILE: 1.x/Chapter3-2-4/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-2-4</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-2-4</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.sql.DataSource;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/DataSourceConfig.java
================================================
package com.didispace;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.sql.DataSource;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/26 下午9:11.
* @blog http://blog.didispace.com
*/
@Configuration
public class DataSourceConfig {
@Bean(name = "primaryDataSource")
@Qualifier("primaryDataSource")
@ConfigurationProperties(prefix="spring.datasource.primary")
public DataSource primaryDataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "secondaryDataSource")
@Qualifier("secondaryDataSource")
@Primary
@ConfigurationProperties(prefix="spring.datasource.secondary")
public DataSource secondaryDataSource() {
return DataSourceBuilder.create().build();
}
}
================================================
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/PrimaryConfig.java
================================================
package com.didispace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManager;
import javax.sql.DataSource;
import java.util.Map;
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef="entityManagerFactoryPrimary",
transactionManagerRef="transactionManagerPrimary",
basePackages= { "com.didispace.domain.p" }) //设置Repository所在位置
public class PrimaryConfig {
@Autowired @Qualifier("primaryDataSource")
private DataSource primaryDataSource;
@Primary
@Bean(name = "entityManagerPrimary")
public EntityManager entityManager(EntityManagerFactoryBuilder builder) {
return entityManagerFactoryPrimary(builder).getObject().createEntityManager();
}
@Primary
@Bean(name = "entityManagerFactoryPrimary")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary (EntityManagerFactoryBuilder builder) {
return builder
.dataSource(primaryDataSource)
.properties(getVendorProperties(primaryDataSource))
.packages("com.didispace.domain.p") //设置实体类所在位置
.persistenceUnit("primaryPersistenceUnit")
.build();
}
@Autowired
private JpaProperties jpaProperties;
private Map<String, String> getVendorProperties(DataSource dataSource) {
return jpaProperties.getHibernateProperties(dataSource);
}
@Primary
@Bean(name = "transactionManagerPrimary")
public PlatformTransactionManager transactionManagerPrimary(EntityManagerFactoryBuilder builder) {
return new JpaTransactionManager(entityManagerFactoryPrimary(builder).getObject());
}
}
================================================
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/SecondaryConfig.java
================================================
package com.didispace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManager;
import javax.sql.DataSource;
import java.util.Map;
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef="entityManagerFactorySecondary",
transactionManagerRef="transactionManagerSecondary",
basePackages= { "com.didispace.domain.s" }) //设置Repository所在位置
public class SecondaryConfig {
@Autowired @Qualifier("secondaryDataSource")
private DataSource secondaryDataSource;
@Bean(name = "entityManagerSecondary")
public EntityManager entityManager(EntityManagerFactoryBuilder builder) {
return entityManagerFactorySecondary(builder).getObject().createEntityManager();
}
@Bean(name = "entityManagerFactorySecondary")
public LocalContainerEntityManagerFactoryBean entityManagerFactorySecondary (EntityManagerFactoryBuilder builder) {
return builder
.dataSource(secondaryDataSource)
.properties(getVendorProperties(secondaryDataSource))
.packages("com.didispace.domain.s") //设置实体类所在位置
.persistenceUnit("secondaryPersistenceUnit")
.build();
}
@Autowired
private JpaProperties jpaProperties;
private Map<String, String> getVendorProperties(DataSource dataSource) {
return jpaProperties.getHibernateProperties(dataSource);
}
@Bean(name = "transactionManagerSecondary")
PlatformTransactionManager transactionManagerSecondary(EntityManagerFactoryBuilder builder) {
return new JpaTransactionManager(entityManagerFactorySecondary(builder).getObject());
}
}
================================================
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/domain/p/User.java
================================================
package com.didispace.domain.p;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/21 下午3:35.
* @blog http://blog.didispace.com
*/
@Entity
public class User {
@Id
@GeneratedValue
private Long id;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private Integer age;
public User(){}
public User(String name, Integer age) {
this.name = name;
this.age = age;
}
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 Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
================================================
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/domain/p/UserRepository.java
================================================
package com.didispace.domain.p;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/23 下午2:34.
* @blog http://blog.didispace.com
*/
public interface UserRepository extends JpaRepository<User, Long> {
}
================================================
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/domain/s/Message.java
================================================
package com.didispace.domain.s;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/21 下午3:35.
* @blog http://blog.didispace.com
*/
@Entity
public class Message {
@Id
@GeneratedValue
private Long id;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String content;
public Message(){}
public Message(String name, String content) {
this.name = name;
this.content = content;
}
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 String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
================================================
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/domain/s/MessageRepository.java
================================================
package com.didispace.domain.s;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/23 下午2:34.
* @blog http://blog.didispace.com
*/
public interface MessageRepository extends JpaRepository<Message, Long> {
}
================================================
FILE: 1.x/Chapter3-2-4/src/main/resources/application.properties
================================================
spring.datasource.primary.url=jdbc:mysql://localhost:3306/test1
spring.datasource.primary.username=root
spring.datasource.primary.password=52261340
spring.datasource.primary.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.secondary.url=jdbc:mysql://localhost:3306/test2
spring.datasource.secondary.username=root
spring.datasource.secondary.password=52261340
spring.datasource.secondary.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.hbm2ddl.auto=create-drop
================================================
FILE: 1.x/Chapter3-2-4/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.domain.p.User;
import com.didispace.domain.p.UserRepository;
import com.didispace.domain.s.Message;
import com.didispace.domain.s.MessageRepository;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class)
public class ApplicationTests {
@Autowired
private UserRepository userRepository;
@Autowired
private MessageRepository messageRepository;
@Before
public void setUp() {
}
@Test
public void test() throws Exception {
userRepository.save(new User("aaa", 10));
userRepository.save(new User("bbb", 20));
userRepository.save(new User("ccc", 30));
userRepository.save(new User("ddd", 40));
userRepository.save(new User("eee", 50));
Assert.assertEquals(5, userRepository.findAll().size());
messageRepository.save(new Message("o1", "aaaaaaaaaa"));
messageRepository.save(new Message("o2", "bbbbbbbbbb"));
messageRepository.save(new Message("o3", "cccccccccc"));
Assert.assertEquals(3, messageRepository.findAll().size());
}
}
================================================
FILE: 1.x/Chapter3-2-5/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-2-5</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-2-5</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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-redis</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-2-5/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
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);
}
}
================================================
FILE: 1.x/Chapter3-2-5/src/main/java/com/didispace/RedisConfig.java
================================================
package com.didispace;
import com.didispace.domain.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.*;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/4/15 下午3:19.
* @blog http://blog.didispace.com
*/
@Configuration
public class RedisConfig {
@Bean
JedisConnectionFactory jedisConnectionFactory() {
return new JedisConnectionFactory();
}
@Bean
public RedisTemplate<String, User> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, User> template = new RedisTemplate<String, User>();
template.setConnectionFactory(jedisConnectionFactory());
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new RedisObjectSerializer());
return template;
}
}
================================================
FILE: 1.x/Chapter3-2-5/src/main/java/com/didispace/RedisObjectSerializer.java
================================================
package com.didispace;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.serializer.support.DeserializingConverter;
import org.springframework.core.serializer.support.SerializingConverter;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;
public class RedisObjectSerializer implements RedisSerializer<Object> {
private Converter<Object, byte[]> serializer = new SerializingConverter();
private Converter<byte[], Object> deserializer = new DeserializingConverter();
static final byte[] EMPTY_ARRAY = new byte[0];
public Object deserialize(byte[] bytes) {
if (isEmpty(bytes)) {
return null;
}
try {
return deserializer.convert(bytes);
} catch (Exception ex) {
throw new SerializationException("Cannot deserialize", ex);
}
}
public byte[] serialize(Object object) {
if (object == null) {
return EMPTY_ARRAY;
}
try {
return serializer.convert(object);
} catch (Exception ex) {
return EMPTY_ARRAY;
}
}
private boolean isEmpty(byte[] data) {
return (data == null || data.length == 0);
}
}
================================================
FILE: 1.x/Chapter3-2-5/src/main/java/com/didispace/domain/User.java
================================================
package com.didispace.domain;
import java.io.Serializable;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/4/15 下午1:58.
* @blog http://blog.didispace.com
*/
public class User implements Serializable {
private static final long serialVersionUID = -1L;
private String username;
private Integer age;
public User(String username, Integer age) {
this.username = username;
this.age = age;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
================================================
FILE: 1.x/Chapter3-2-5/src/main/resources/application.properties
================================================
# REDIS (RedisProperties)
# Redis数据库索引(默认为0)
spring.redis.database=0
# Redis服务器地址
spring.redis.host=localhost
# Redis服务器连接端口
spring.redis.port=6379
# Redis服务器连接密码(默认为空)
spring.redis.password=
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.pool.max-idle=8
# 连接池中的最小空闲连接
spring.redis.pool.min-idle=0
# 连接超时时间(毫秒)
spring.redis.timeout=0
================================================
FILE: 1.x/Chapter3-2-5/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.domain.User;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class)
public class ApplicationTests {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private RedisTemplate<String, User> redisTemplate;
@Test
public void test() throws Exception {
// 保存字符串
stringRedisTemplate.opsForValue().set("aaa", "111");
Assert.assertEquals("111", stringRedisTemplate.opsForValue().get("aaa"));
// 保存对象
User user = new User("超人", 20);
redisTemplate.opsForValue().set(user.getUsername(), user);
user = new User("蝙蝠侠", 30);
redisTemplate.opsForValue().set(user.getUsername(), user);
user = new User("蜘蛛侠", 40);
redisTemplate.opsForValue().set(user.getUsername(), user);
Assert.assertEquals(20, redisTemplate.opsForValue().get("超人").getAge().longValue());
Assert.assertEquals(30, redisTemplate.opsForValue().get("蝙蝠侠").getAge().longValue());
Assert.assertEquals(40, redisTemplate.opsForValue().get("蜘蛛侠").getAge().longValue());
}
}
================================================
FILE: 1.x/Chapter3-2-6/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>demo</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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-data-mongodb</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-2-6/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
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);
}
}
================================================
FILE: 1.x/Chapter3-2-6/src/main/java/com/didispace/domain/User.java
================================================
package com.didispace.domain;
import org.springframework.data.annotation.Id;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/4/27 下午10:04.
* @blog http://blog.didispace.com
*/
public class User {
@Id
private Long id;
private String username;
private Integer age;
public User(Long id, String username, Integer age) {
this.id = id;
this.username = username;
this.age = age;
}
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 Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
================================================
FILE: 1.x/Chapter3-2-6/src/main/java/com/didispace/domain/UserRepository.java
================================================
package com.didispace.domain;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/4/27 下午10:16.
* @blog http://blog.didispace.com
*/
public interface UserRepository extends MongoRepository<User, Long> {
User findByUsername(String username);
}
================================================
FILE: 1.x/Chapter3-2-6/src/main/resources/application.properties
================================================
spring.data.mongodb.uri=mongodb://name:pass@localhost:27017/test
================================================
FILE: 1.x/Chapter3-2-6/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.domain.User;
import com.didispace.domain.UserRepository;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class)
public class ApplicationTests {
@Autowired
private UserRepository userRepository;
@Before
public void setUp() {
userRepository.deleteAll();
}
@Test
public void test() throws Exception {
// 创建三个User,并验证User总数
userRepository.save(new User(1L, "didi", 30));
userRepository.save(new User(2L, "mama", 40));
userRepository.save(new User(3L, "kaka", 50));
Assert.assertEquals(3, userRepository.findAll().size());
// 删除一个User,再验证User总数
User u = userRepository.findOne(1L);
userRepository.delete(u);
Assert.assertEquals(2, userRepository.findAll().size());
// 删除一个User,再验证User总数
u = userRepository.findByUsername("mama");
userRepository.delete(u);
Assert.assertEquals(1, userRepository.findAll().size());
}
}
================================================
FILE: 1.x/Chapter3-2-7/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-2-7</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-2-7</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-2-7/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
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);
}
}
================================================
FILE: 1.x/Chapter3-2-7/src/main/java/com/didispace/domain/User.java
================================================
package com.didispace.domain;
public class User {
private Long id;
private String name;
private Integer age;
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 Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
================================================
FILE: 1.x/Chapter3-2-7/src/main/java/com/didispace/domain/UserMapper.java
================================================
package com.didispace.domain;
import org.apache.ibatis.annotations.*;
@Mapper
public interface UserMapper {
@Select("SELECT * FROM USER WHERE NAME = #{name}")
User findByName(@Param("name") String name);
@Insert("INSERT INTO USER(NAME, AGE) VALUES(#{name}, #{age})")
int insert(@Param("name") String name, @Param("age") Integer age);
}
================================================
FILE: 1.x/Chapter3-2-7/src/main/resources/application.properties
================================================
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
================================================
FILE: 1.x/Chapter3-2-7/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.domain.User;
import com.didispace.domain.UserMapper;
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.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@Transactional
public class ApplicationTests {
@Autowired
private UserMapper userMapper;
@Test
@Rollback
public void findByName() throws Exception {
userMapper.insert("AAA", 20);
User u = userMapper.findByName("AAA");
Assert.assertEquals(20, u.getAge().intValue());
}
}
================================================
FILE: 1.x/Chapter3-2-8/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-2-8</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-2-8</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-2-8/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
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);
}
}
================================================
FILE: 1.x/Chapter3-2-8/src/main/java/com/didispace/domain/User.java
================================================
package com.didispace.domain;
public class User {
private Long id;
private String name;
private Integer age;
public User() {
}
public User(Long id, String name, Integer age) {
this.id = id;
this.name = name;
this.age = age;
}
public User(String name, Integer age) {
this.name = name;
this.age = age;
}
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 Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
================================================
FILE: 1.x/Chapter3-2-8/src/main/java/com/didispace/domain/UserMapper.java
================================================
package com.didispace.domain;
import org.apache.ibatis.annotations.*;
import java.util.List;
import java.util.Map;
@Mapper
public interface UserMapper {
@Select("SELECT * FROM user WHERE name = #{name}")
User findByName(@Param("name") String name);
@Results({
@Result(property = "name", column = "name"),
@Result(property = "age", column = "age")
})
@Select("SELECT name, age FROM user")
List<User> findAll();
@Insert("INSERT INTO user(name, age) VALUES(#{name}, #{age})")
int insert(@Param("name") String name, @Param("age") Integer age);
@Update("UPDATE user SET age=#{age} WHERE name=#{name}")
void update(User user);
@Delete("DELETE FROM user WHERE id =#{id}")
void delete(Long id);
@Insert("INSERT INTO user(name, age) VALUES(#{name}, #{age})")
int insertByUser(User user);
@Insert("INSERT INTO user(name, age) VALUES(#{name,jdbcType=VARCHAR}, #{age,jdbcType=INTEGER})")
int insertByMap(Map<String, Object> map);
}
================================================
FILE: 1.x/Chapter3-2-8/src/main/resources/application.properties
================================================
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
================================================
FILE: 1.x/Chapter3-2-8/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.domain.User;
import com.didispace.domain.UserMapper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@Transactional
public class ApplicationTests {
@Autowired
private UserMapper userMapper;
@Test
@Rollback
public void testUserMapper() throws Exception {
// insert一条数据,并select出来验证
userMapper.insert("AAA", 20);
User u = userMapper.findByName("AAA");
Assert.assertEquals(20, u.getAge().intValue());
// update一条数据,并select出来验证
u.setAge(30);
userMapper.update(u);
u = userMapper.findByName("AAA");
Assert.assertEquals(30, u.getAge().intValue());
// 删除这条数据,并select验证
userMapper.delete(u.getId());
u = userMapper.findByName("AAA");
Assert.assertEquals(null, u);
u = new User("BBB", 30);
userMapper.insertByUser(u);
Assert.assertEquals(30, userMapper.findByName("BBB").getAge().intValue());
Map<String, Object> map = new HashMap<>();
map.put("name", "CCC");
map.put("age", 40);
userMapper.insertByMap(map);
Assert.assertEquals(40, userMapper.findByName("CCC").getAge().intValue());
List<User> userList = userMapper.findAll();
for(User user : userList) {
Assert.assertEquals(null, user.getId());
Assert.assertNotEquals(null, user.getName());
}
}
}
================================================
FILE: 1.x/Chapter3-2-9/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-2-9</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-2-9</name>
<description>Spring Boot with JDBCTemplate</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>5.0.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-2-9/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
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);
}
}
================================================
FILE: 1.x/Chapter3-2-9/src/main/java/com/didispace/service/UserService.java
================================================
package com.didispace.service;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/17 下午7:04.
* @blog http://blog.didispace.com
*/
public interface UserService {
/**
* 新增一个用户
* @param name
* @param age
*/
void create(String name, Integer age);
/**
* 根据name删除一个用户高
* @param name
*/
void deleteByName(String name);
/**
* 获取用户总量
*/
Integer getAllUsers();
/**
* 删除所有用户
*/
void deleteAllUsers();
}
================================================
FILE: 1.x/Chapter3-2-9/src/main/java/com/didispace/service/UserServiceImpl.java
================================================
package com.didispace.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/17 下午6:44.
* @blog http://blog.didispace.com
*/
@Service
public class UserServiceImpl implements UserService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public void create(String name, Integer age) {
jdbcTemplate.update("insert into user(NAME, AGE) values(?, ?)", name, age);
}
@Override
public void deleteByName(String name) {
jdbcTemplate.update("delete from user where NAME = ?", name);
}
@Override
public Integer getAllUsers() {
return jdbcTemplate.queryForObject("select count(1) from user", Integer.class);
}
@Override
public void deleteAllUsers() {
jdbcTemplate.update("delete from user");
}
}
================================================
FILE: 1.x/Chapter3-2-9/src/main/resources/application.properties
================================================
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
flyway.locations=classpath:/db
================================================
FILE: 1.x/Chapter3-2-9/src/main/resources/db/V1__Base_version.sql
================================================
DROP TABLE IF EXISTS `user` ;
CREATE TABLE `user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(30) NOT NULL COMMENT '姓名',
`age` int(5) DEFAULT NULL COMMENT '年龄',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
================================================
FILE: 1.x/Chapter3-2-9/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.service.UserService;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class ApplicationTests {
@Autowired
private UserService userSerivce;
@Before
public void setUp() {
// 准备,清空user表
userSerivce.deleteAllUsers();
}
@Test
public void test() throws Exception {
// 插入5个用户
userSerivce.create("a", 1);
userSerivce.create("b", 2);
userSerivce.create("c", 3);
userSerivce.create("d", 4);
userSerivce.create("e", 5);
// 查数据库,应该有5个用户
Assert.assertEquals(5, userSerivce.getAllUsers().intValue());
// 删除两个用户
userSerivce.deleteByName("a");
userSerivce.deleteByName("e");
// 查数据库,应该有5个用户
Assert.assertEquals(3, userSerivce.getAllUsers().intValue());
}
}
================================================
FILE: 1.x/Chapter3-3-1/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter3-3-1</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter3-3-1</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter3-3-1/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
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);
}
}
================================================
FILE: 1.x/Chapter3-3-1/src/main/java/com/didispace/domain/User.java
================================================
package com.didispace.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/21 下午3:35.
* @blog http://blog.didispace.com
*/
@Entity
public class User {
@Id
@GeneratedValue
private Long id;
@Column(nullable = false, length = 5)
private String name;
@Column(nullable = false)
private Integer age;
public User(){}
public User(String name, Integer age) {
this.name = name;
this.age = age;
}
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 Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
================================================
FILE: 1.x/Chapter3-3-1/src/main/java/com/didispace/domain/UserRepository.java
================================================
package com.didispace.domain;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/3/23 下午2:34.
* @blog http://blog.didispace.com
*/
public interface UserRepository extends JpaRepository<User, Long> {
User findByName(String name);
User findByNameAndAge(String name, Integer age);
@Query("from User u where u.name=:name")
User findUser(@Param("name") String name);
}
================================================
FILE: 1.x/Chapter3-3-1/src/main/java/com/didispace/service/UserService.java
================================================
package com.didispace.service;
import com.didispace.domain.User;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
/**
* Created by Administrator on 2016/5/27.
*/
public interface UserService {
@Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
User login(String name, String password);
}
================================================
FILE: 1.x/Chapter3-3-1/src/main/resources/application.properties
================================================
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.hbm2ddl.auto=create
================================================
FILE: 1.x/Chapter3-3-1/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.domain.User;
import com.didispace.domain.UserRepository;
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 org.springframework.transaction.annotation.Transactional;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class)
public class ApplicationTests {
@Autowired
private UserRepository userRepository;
@Test
@Transactional
public void test() throws Exception {
// 创建10条记录
userRepository.save(new User("AAA", 10));
userRepository.save(new User("BBB", 20));
userRepository.save(new User("CCC", 30));
userRepository.save(new User("DDD", 40));
userRepository.save(new User("EEE", 50));
userRepository.save(new User("FFF", 60));
userRepository.save(new User("GGG", 70));
userRepository.save(new User("HHHHHHHHH", 80));
userRepository.save(new User("III", 90));
userRepository.save(new User("JJJ", 100));
// 测试findAll, 查询所有记录
Assert.assertEquals(10, userRepository.findAll().size());
// 测试findByName, 查询姓名为FFF的User
Assert.assertEquals(60, userRepository.findByName("FFF").getAge().longValue());
// 测试findUser, 查询姓名为FFF的User
Assert.assertEquals(60, userRepository.findUser("FFF").getAge().longValue());
// 测试findByNameAndAge, 查询姓名为FFF并且年龄为60的User
Assert.assertEquals("FFF", userRepository.findByNameAndAge("FFF", 60).getName());
// 测试删除姓名为AAA的User
userRepository.delete(userRepository.findByName("AAA"));
// 测试findAll, 查询所有记录, 验证上面的删除是否成功
Assert.assertEquals(9, userRepository.findAll().size());
}
}
================================================
FILE: 1.x/Chapter4-1-1/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter4-1-1</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter4-1-1</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter4-1-1/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter4-1-1/src/main/java/com/didispace/task/ScheduledTasks.java
================================================
package com.didispace.task;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Date;
@Component
public class ScheduledTasks {
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
@Scheduled(fixedRate = 5000)
public void reportCurrentTime() {
System.out.println("当前时间:" + dateFormat.format(new Date()));
}
}
================================================
FILE: 1.x/Chapter4-1-1/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter4-1-1/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
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 getHello() throws Exception {
}
}
================================================
FILE: 1.x/Chapter4-1-2/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter4-1-2</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter4-1-2</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter4-1-2/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableAsync
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter4-1-2/src/main/java/com/didispace/async/Task.java
================================================
package com.didispace.async;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;
import java.util.Random;
import java.util.concurrent.Future;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/5/16 下午12:58.
* @blog http://blog.didispace.com
*/
@Component
public class Task {
public static Random random =new Random();
@Async
public Future<String> doTaskOne() throws Exception {
System.out.println("开始做任务一");
long start = System.currentTimeMillis();
Thread.sleep(random.nextInt(10000));
long end = System.currentTimeMillis();
System.out.println("完成任务一,耗时:" + (end - start) + "毫秒");
return new AsyncResult<>("任务一完成");
}
@Async
public Future<String> doTaskTwo() throws Exception {
System.out.println("开始做任务二");
long start = System.currentTimeMillis();
Thread.sleep(random.nextInt(10000));
long end = System.currentTimeMillis();
System.out.println("完成任务二,耗时:" + (end - start) + "毫秒");
return new AsyncResult<>("任务二完成");
}
@Async
public Future<String> doTaskThree() throws Exception {
System.out.println("开始做任务三");
long start = System.currentTimeMillis();
Thread.sleep(random.nextInt(10000));
long end = System.currentTimeMillis();
System.out.println("完成任务三,耗时:" + (end - start) + "毫秒");
return new AsyncResult<>("任务三完成");
}
}
================================================
FILE: 1.x/Chapter4-1-2/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter4-1-2/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.async.Task;
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 java.util.concurrent.Future;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
public class ApplicationTests {
@Autowired
private Task task;
@Test
public void test() throws Exception {
long start = System.currentTimeMillis();
Future<String> task1 = task.doTaskOne();
Future<String> task2 = task.doTaskTwo();
Future<String> task3 = task.doTaskThree();
while(true) {
if(task1.isDone() && task2.isDone() && task3.isDone()) {
// 三个任务都调用完成,退出循环等待
break;
}
Thread.sleep(1000);
}
long end = System.currentTimeMillis();
System.out.println("任务全部完成,总耗时:" + (end - start) + "毫秒");
}
}
================================================
FILE: 1.x/Chapter4-1-3/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter4-1-3</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter4-1-3</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter4-1-3/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@EnableAsync
@Configuration
class TaskPoolConfig {
@Bean("taskExecutor")
public Executor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(10);
executor.setMaxPoolSize(20);
executor.setQueueCapacity(200);
executor.setKeepAliveSeconds(60);
executor.setThreadNamePrefix("taskExecutor-");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
return executor;
}
}
}
================================================
FILE: 1.x/Chapter4-1-3/src/main/java/com/didispace/async/Task.java
================================================
package com.didispace.async;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.Random;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/5/16 下午12:58.
* @blog http://blog.didispace.com
*/
@Slf4j
@Component
public class Task {
public static Random random = new Random();
@Async("taskExecutor")
public void doTaskOne() throws Exception {
log.info("开始做任务一");
long start = System.currentTimeMillis();
Thread.sleep(random.nextInt(10000));
long end = System.currentTimeMillis();
log.info("完成任务一,耗时:" + (end - start) + "毫秒");
}
@Async("taskExecutor")
public void doTaskTwo() throws Exception {
log.info("开始做任务二");
long start = System.currentTimeMillis();
Thread.sleep(random.nextInt(10000));
long end = System.currentTimeMillis();
log.info("完成任务二,耗时:" + (end - start) + "毫秒");
}
@Async("taskExecutor")
public void doTaskThree() throws Exception {
log.info("开始做任务三");
long start = System.currentTimeMillis();
Thread.sleep(random.nextInt(10000));
long end = System.currentTimeMillis();
log.info("完成任务三,耗时:" + (end - start) + "毫秒");
}
}
================================================
FILE: 1.x/Chapter4-1-3/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter4-1-3/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.async.Task;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class ApplicationTests {
@Autowired
private Task task;
@Test
public void test() throws Exception {
task.doTaskOne();
task.doTaskTwo();
task.doTaskThree();
Thread.currentThread().join();
}
}
================================================
FILE: 1.x/Chapter4-1-4/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter4-1-4</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter4-1-4</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter4-1-4/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import java.util.concurrent.Executor;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@EnableAsync
@Configuration
class TaskPoolConfig {
@Bean("taskExecutor")
public Executor taskExecutor() {
ThreadPoolTaskScheduler executor = new ThreadPoolTaskScheduler();
executor.setPoolSize(20);
executor.setThreadNamePrefix("taskExecutor-");
executor.setWaitForTasksToCompleteOnShutdown(true);
executor.setAwaitTerminationSeconds(60);
return executor;
}
}
}
================================================
FILE: 1.x/Chapter4-1-4/src/main/java/com/didispace/async/Task.java
================================================
package com.didispace.async;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/5/16 下午12:58.
* @blog http://blog.didispace.com
*/
@Slf4j
@Component
public class Task {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Async("taskExecutor")
public void doTaskOne() throws Exception {
log.info("开始做任务一");
long start = System.currentTimeMillis();
log.info(stringRedisTemplate.randomKey());
long end = System.currentTimeMillis();
log.info("完成任务一,耗时:" + (end - start) + "毫秒");
}
@Async("taskExecutor")
public void doTaskTwo() throws Exception {
log.info("开始做任务二");
long start = System.currentTimeMillis();
log.info(stringRedisTemplate.randomKey());
long end = System.currentTimeMillis();
log.info("完成任务二,耗时:" + (end - start) + "毫秒");
}
@Async("taskExecutor")
public void doTaskThree() throws Exception {
log.info("开始做任务三");
long start = System.currentTimeMillis();
log.info(stringRedisTemplate.randomKey());
long end = System.currentTimeMillis();
log.info("完成任务三,耗时:" + (end - start) + "毫秒");
}
}
================================================
FILE: 1.x/Chapter4-1-4/src/main/resources/application.properties
================================================
spring.redis.pool.max-wait=5000
spring.redis.pool.max-active=10
================================================
FILE: 1.x/Chapter4-1-4/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.async.Task;
import lombok.SneakyThrows;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class ApplicationTests {
@Autowired
private Task task;
@Test
@SneakyThrows
public void test() {
for (int i = 0; i < 10000; i++) {
task.doTaskOne();
task.doTaskTwo();
task.doTaskThree();
if (i == 9999) {
System.exit(0);
}
}
}
}
================================================
FILE: 1.x/Chapter4-1-5/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter4-1-5</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter4-1-5</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</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.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter4-1-5/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@EnableAsync
@Configuration
class TaskPoolConfig {
@Bean("taskExecutor")
public Executor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(10);
executor.setMaxPoolSize(20);
executor.setQueueCapacity(200);
executor.setKeepAliveSeconds(60);
executor.setThreadNamePrefix("taskExecutor-");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
return executor;
}
}
}
================================================
FILE: 1.x/Chapter4-1-5/src/main/java/com/didispace/async/Task.java
================================================
package com.didispace.async;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;
import java.util.Random;
import java.util.concurrent.Future;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/5/16 下午12:58.
* @blog http://blog.didispace.com
*/
@Slf4j
@Component
public class Task {
public static Random random = new Random();
@Async("taskExecutor")
public Future<String> run() throws Exception {
long sleep = random.nextInt(10000);
log.info("开始任务,需耗时:" + sleep + "毫秒");
Thread.sleep(sleep);
log.info("完成任务");
return new AsyncResult<>("test");
}
}
================================================
FILE: 1.x/Chapter4-1-5/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter4-1-5/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import com.didispace.async.Task;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class ApplicationTests {
@Autowired
private Task task;
@Test
public void test() throws Exception {
Future<String> futureResult = task.run();
String result = futureResult.get(5, TimeUnit.SECONDS);
log.info(result);
}
}
================================================
FILE: 1.x/Chapter4-2-2/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter4-2-2</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter4-2-2</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter4-2-2/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.apache.log4j.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter4-2-2/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter4-2-2/src/main/resources/log4j.properties
================================================
# LOG4J配置
log4j.rootCategory=INFO, stdout, file, errorfile
log4j.category.com.didispace=DEBUG, didifile
log4j.logger.error=errorfile
# 控制台输出
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
# root日志输出
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.file=logs/all.log
log4j.appender.file.DatePattern='.'yyyy-MM-dd
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
# error日志输出
log4j.appender.errorfile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.errorfile.file=logs/error.log
log4j.appender.errorfile.DatePattern='.'yyyy-MM-dd
log4j.appender.errorfile.Threshold = ERROR
log4j.appender.errorfile.layout=org.apache.log4j.PatternLayout
log4j.appender.errorfile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
# com.didispace下的日志输出
log4j.appender.didifile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.didifile.file=logs/my.log
log4j.appender.didifile.DatePattern='.'yyyy-MM-dd
log4j.appender.didifile.layout=org.apache.log4j.PatternLayout
log4j.appender.didifile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L ---- %m%n
================================================
FILE: 1.x/Chapter4-2-2/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import org.apache.log4j.Logger;
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 {
private Logger logger = Logger.getLogger(getClass());
@Test
public void test() throws Exception {
logger.info("输出info");
logger.debug("输出debug");
logger.error("输出error");
}
}
================================================
FILE: 1.x/Chapter4-2-3/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter4-2-3</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter4-2-3</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter4-2-3/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.apache.log4j.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
================================================
FILE: 1.x/Chapter4-2-3/src/main/resources/application-dev.properties
================================================
logging.level.com.didispace=INFO
================================================
FILE: 1.x/Chapter4-2-3/src/main/resources/application-prod.properties
================================================
logging.level.com.didispace=INFO
================================================
FILE: 1.x/Chapter4-2-3/src/main/resources/application-test.properties
================================================
logging.level.com.didispace=DEBUG
================================================
FILE: 1.x/Chapter4-2-3/src/main/resources/application.properties
================================================
spring.profiles.active=dev
================================================
FILE: 1.x/Chapter4-2-3/src/main/resources/log4j.properties
================================================
# LOG4J配置
log4j.rootCategory=INFO, stdout, file, errorfile
log4j.category.com.didispace=${logging.level.com.didispace}, didifile
log4j.logger.error=errorfile
# 控制台输出
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
# root日志输出
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.file=logs/all.log
log4j.appender.file.DatePattern='.'yyyy-MM-dd
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
# error日志输出
log4j.appender.errorfile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.errorfile.file=logs/error.log
log4j.appender.errorfile.DatePattern='.'yyyy-MM-dd
log4j.appender.errorfile.Threshold = ERROR
log4j.appender.errorfile.layout=org.apache.log4j.PatternLayout
log4j.appender.errorfile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
# com.didispace下的日志输出
log4j.appender.didifile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.didifile.file=logs/my.log
log4j.appender.didifile.DatePattern='.'yyyy-MM-dd
log4j.appender.didifile.layout=org.apache.log4j.PatternLayout
log4j.appender.didifile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L ---- %m%n
================================================
FILE: 1.x/Chapter4-2-3/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import org.apache.log4j.Logger;
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 {
private Logger logger = Logger.getLogger(getClass());
@Test
public void test() throws Exception {
logger.info("输出info");
logger.debug("输出debug");
logger.error("输出error");
}
}
================================================
FILE: 1.x/Chapter4-2-4/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter4-2-4</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter4-2-4</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter4-2-4/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
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);
}
}
================================================
FILE: 1.x/Chapter4-2-4/src/main/java/com/didispace/aspect/WebLogAspect.java
================================================
package com.didispace.aspect;
import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
/**
* Web层日志切面
*
* @author 程序猿DD
* @version 1.0.0
* @date 16/5/17 上午10:42.
* @blog http://blog.didispace.com
*/
@Aspect
@Order(5)
@Component
public class WebLogAspect {
private Logger logger = Logger.getLogger(getClass());
ThreadLocal<Long> startTime = new ThreadLocal<>();
@Pointcut("execution(public * com.didispace.web..*.*(..))")
public void webLog(){}
@Before("webLog()")
public void doBefore(JoinPoint joinPoint) throws Throwable {
startTime.set(System.currentTimeMillis());
// 接收到请求,记录请求内容
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
// 记录下请求内容
logger.info("URL : " + request.getRequestURL().toString());
logger.info("HTTP_METHOD : " + request.getMethod());
logger.info("IP : " + request.getRemoteAddr());
logger.info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
logger.info("ARGS : " + Arrays.toString(joinPoint.getArgs()));
}
@AfterReturning(returning = "ret", pointcut = "webLog()")
public void doAfterReturning(Object ret) throws Throwable {
// 处理完请求,返回内容
logger.info("RESPONSE : " + ret);
logger.info("SPEND TIME : " + (System.currentTimeMillis() - startTime.get()));
}
}
================================================
FILE: 1.x/Chapter4-2-4/src/main/java/com/didispace/web/HelloController.java
================================================
package com.didispace.web;
import org.springframework.web.bind.annotation.*;
/**
* @author 程序猿DD
* @version 1.0.0
* @date 16/5/19 下午1:27.
* @blog http://blog.didispace.com
*/
@RestController
public class HelloController {
@RequestMapping(value = "/hello", method = RequestMethod.GET)
@ResponseBody
public String hello(@RequestParam String name) {
return "Hello " + name;
}
}
================================================
FILE: 1.x/Chapter4-2-4/src/main/resources/application.properties
================================================
================================================
FILE: 1.x/Chapter4-2-4/src/main/resources/log4j.properties
================================================
# LOG4J配置
log4j.rootCategory=INFO, stdout, file, errorfile
log4j.category.com.didispace=DEBUG, didifile
log4j.logger.error=errorfile
# 控制台输出
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
# root日志输出
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.file=logs/all.log
log4j.appender.file.DatePattern='.'yyyy-MM-dd
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
# error日志输出
log4j.appender.errorfile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.errorfile.file=logs/error.log
log4j.appender.errorfile.DatePattern='.'yyyy-MM-dd
log4j.appender.errorfile.Threshold = ERROR
log4j.appender.errorfile.layout=org.apache.log4j.PatternLayout
log4j.appender.errorfile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
# com.didispace下的日志输出
log4j.appender.didifile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.didifile.file=logs/my.log
log4j.appender.didifile.DatePattern='.'yyyy-MM-dd
log4j.appender.didifile.layout=org.apache.log4j.PatternLayout
log4j.appender.didifile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L ---- %m%n
================================================
FILE: 1.x/Chapter4-2-4/src/test/java/com/didispace/ApplicationTests.java
================================================
package com.didispace;
import org.apache.log4j.Logger;
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 {
private Logger logger = Logger.getLogger(getClass());
@Test
public void test() throws Exception {
logger.info("输出info");
logger.debug("输出debug");
logger.error("输出error");
}
}
================================================
FILE: 1.x/Chapter4-2-5/pom.xml
================================================
<?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.didispace</groupId>
<artifactId>Chapter4-2-5</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Chapter4-2-5</name>
<description>Spring Boot project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>3.2.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: 1.x/Chapter4-2-5/src/main/java/com/didispace/Application.java
================================================
package com.didispace;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfi
gitextract_o44g23q_/ ├── .gitignore ├── .gitmodules ├── 1.x/ │ ├── Chapter1/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Chapter1Application.java │ │ │ │ └── web/ │ │ │ │ └── HelloController.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── Chapter1ApplicationTests.java │ ├── Chapter2-1-1/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ ├── service/ │ │ │ │ │ └── BlogProperties.java │ │ │ │ └── web/ │ │ │ │ └── HelloController.java │ │ │ └── resources/ │ │ │ ├── application-dev.properties │ │ │ ├── application-prod.properties │ │ │ ├── application-test.properties │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter2-1-2/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ ├── Application.java │ │ │ ├── ApplicationEnvironmentPreparedEventListener.java │ │ │ ├── ApplicationFailedEventListener.java │ │ │ ├── ApplicationPreparedEventListener.java │ │ │ ├── ApplicationReadyEventListener.java │ │ │ ├── ApplicationStartedEventListener.java │ │ │ └── ApplicationStartingEventListener.java │ │ └── resources/ │ │ ├── META-INF/ │ │ │ └── spring.factories │ │ └── application.properties │ ├── Chapter2-2-1/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ ├── Application.java │ │ │ ├── FooProperties.java │ │ │ └── PostInfo.java │ │ └── resources/ │ │ └── application.properties │ ├── Chapter3-1-1/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ ├── domain/ │ │ │ │ │ └── User.java │ │ │ │ └── web/ │ │ │ │ ├── HelloController.java │ │ │ │ └── UserController.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-1-2/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── web/ │ │ │ │ └── HelloController.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── templates/ │ │ │ └── index.html │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-1-3/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── web/ │ │ │ │ └── HelloController.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── templates/ │ │ │ └── index.ftl │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-1-4/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── web/ │ │ │ │ └── HelloController.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── templates/ │ │ │ └── index.vm │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-1-5/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ ├── Application.java │ │ │ ├── Swagger2.java │ │ │ ├── domain/ │ │ │ │ └── User.java │ │ │ └── web/ │ │ │ ├── HelloController.java │ │ │ └── UserController.java │ │ └── resources/ │ │ └── application.properties │ ├── Chapter3-1-6/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ ├── dto/ │ │ │ │ │ └── ErrorInfo.java │ │ │ │ ├── exception/ │ │ │ │ │ ├── GlobalExceptionHandler.java │ │ │ │ │ └── MyException.java │ │ │ │ └── web/ │ │ │ │ └── HelloController.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── templates/ │ │ │ ├── error.html │ │ │ └── index.html │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-1-7/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── Application.java │ │ └── resources/ │ │ └── application.properties │ ├── Chapter3-1-8/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ ├── Application.java │ │ │ └── web/ │ │ │ ├── User.java │ │ │ └── UserController.java │ │ └── resources/ │ │ └── application.properties │ ├── Chapter3-2-1/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── service/ │ │ │ │ ├── UserService.java │ │ │ │ └── UserServiceImpl.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-2-10/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ ├── Person.java │ │ │ │ └── PersonRepository.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── ApplicationTests.java │ │ └── resources/ │ │ ├── application.properties │ │ └── ldap-server.ldif │ ├── Chapter3-2-11/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── Application.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-2-2/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── domain/ │ │ │ │ ├── User.java │ │ │ │ └── UserRepository.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-2-3/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── DataSourceConfig.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-2-4/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ ├── DataSourceConfig.java │ │ │ │ ├── PrimaryConfig.java │ │ │ │ ├── SecondaryConfig.java │ │ │ │ └── domain/ │ │ │ │ ├── p/ │ │ │ │ │ ├── User.java │ │ │ │ │ └── UserRepository.java │ │ │ │ └── s/ │ │ │ │ ├── Message.java │ │ │ │ └── MessageRepository.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-2-5/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ ├── RedisConfig.java │ │ │ │ ├── RedisObjectSerializer.java │ │ │ │ └── domain/ │ │ │ │ └── User.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-2-6/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── domain/ │ │ │ │ ├── User.java │ │ │ │ └── UserRepository.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-2-7/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── domain/ │ │ │ │ ├── User.java │ │ │ │ └── UserMapper.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-2-8/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── domain/ │ │ │ │ ├── User.java │ │ │ │ └── UserMapper.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-2-9/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── service/ │ │ │ │ ├── UserService.java │ │ │ │ └── UserServiceImpl.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── db/ │ │ │ └── V1__Base_version.sql │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter3-3-1/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ ├── domain/ │ │ │ │ │ ├── User.java │ │ │ │ │ └── UserRepository.java │ │ │ │ └── service/ │ │ │ │ └── UserService.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter4-1-1/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── task/ │ │ │ │ └── ScheduledTasks.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter4-1-2/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── async/ │ │ │ │ └── Task.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter4-1-3/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── async/ │ │ │ │ └── Task.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter4-1-4/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── async/ │ │ │ │ └── Task.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter4-1-5/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── async/ │ │ │ │ └── Task.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter4-2-2/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── Application.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── log4j.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter4-2-3/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── Application.java │ │ │ └── resources/ │ │ │ ├── application-dev.properties │ │ │ ├── application-prod.properties │ │ │ ├── application-test.properties │ │ │ ├── application.properties │ │ │ └── log4j.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter4-2-4/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ ├── aspect/ │ │ │ │ │ └── WebLogAspect.java │ │ │ │ └── web/ │ │ │ │ └── HelloController.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── log4j.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter4-2-5/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ ├── aspect/ │ │ │ │ │ └── WebLogAspect.java │ │ │ │ ├── log/ │ │ │ │ │ └── MongoAppender.java │ │ │ │ └── web/ │ │ │ │ └── HelloController.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── log4j.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter4-2-6/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── DemoApplication.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── DemoApplicationTests.java │ ├── Chapter4-3-1/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ ├── WebSecurityConfig.java │ │ │ │ └── web/ │ │ │ │ └── HelloController.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── templates/ │ │ │ ├── hello.html │ │ │ ├── index.html │ │ │ └── login.html │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter4-4-1/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── domain/ │ │ │ │ ├── User.java │ │ │ │ └── UserRepository.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── ehcache.xml │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter4-4-2/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── domain/ │ │ │ │ ├── User.java │ │ │ │ └── UserRepository.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter4-5-1/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── Application.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── templates/ │ │ │ └── template.vm │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter5-2-1/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── HelloApplication.java │ │ │ │ └── rabbit/ │ │ │ │ ├── RabbitConfig.java │ │ │ │ ├── Receiver.java │ │ │ │ └── Sender.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── HelloApplicationTests.java │ ├── Chapter6-1-1/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ ├── Application.java │ │ │ ├── EventConfig.java │ │ │ ├── Events.java │ │ │ ├── StateMachineConfig.java │ │ │ └── States.java │ │ └── resources/ │ │ └── application.properties │ ├── Chapter6-2-1/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── web/ │ │ │ │ └── HelloController.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter9-1-1/ │ │ ├── compute-service/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ ├── main/ │ │ │ │ ├── java/ │ │ │ │ │ └── com/ │ │ │ │ │ └── didispace/ │ │ │ │ │ ├── ComputeServiceApplication.java │ │ │ │ │ └── web/ │ │ │ │ │ └── ComputeController.java │ │ │ │ └── resources/ │ │ │ │ └── application.properties │ │ │ └── test/ │ │ │ └── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── ApplicationTests.java │ │ └── eureka-server/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── Application.java │ │ └── resources/ │ │ └── application.properties │ ├── Chapter9-1-2/ │ │ ├── eureka-feign/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── FeignApplication.java │ │ │ │ ├── service/ │ │ │ │ │ └── ComputeClient.java │ │ │ │ └── web/ │ │ │ │ └── ConsumerController.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── eureka-ribbon/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ ├── RibbonApplication.java │ │ │ └── web/ │ │ │ └── ConsumerController.java │ │ └── resources/ │ │ └── application.properties │ ├── Chapter9-1-3/ │ │ ├── compute-service/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ ├── main/ │ │ │ │ ├── java/ │ │ │ │ │ └── com/ │ │ │ │ │ └── didispace/ │ │ │ │ │ ├── ComputeServiceApplication.java │ │ │ │ │ └── web/ │ │ │ │ │ └── ComputeController.java │ │ │ │ └── resources/ │ │ │ │ └── application.properties │ │ │ └── test/ │ │ │ └── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── ApplicationTests.java │ │ ├── eureka-feign/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ ├── FeignApplication.java │ │ │ ├── service/ │ │ │ │ ├── ComputeClient.java │ │ │ │ └── ComputeClientHystrix.java │ │ │ └── web/ │ │ │ └── ConsumerController.java │ │ ├── eureka-ribbon/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ ├── RibbonApplication.java │ │ │ ├── service/ │ │ │ │ └── ComputeService.java │ │ │ └── web/ │ │ │ └── ConsumerController.java │ │ └── eureka-server/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── Application.java │ │ └── resources/ │ │ └── application.properties │ ├── Chapter9-1-4/ │ │ ├── config-client/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── web/ │ │ │ │ └── TestController.java │ │ │ └── resources/ │ │ │ └── bootstrap.properties │ │ ├── config-repo/ │ │ │ ├── didispace-dev.properties │ │ │ ├── didispace-prod.properties │ │ │ ├── didispace-test.properties │ │ │ └── didispace.properties │ │ └── config-server/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── Application.java │ │ └── resources/ │ │ ├── application.properties │ │ ├── didispace-dev.properties │ │ ├── didispace-prod.properties │ │ ├── didispace-test.properties │ │ └── didispace.properties │ ├── Chapter9-1-5/ │ │ ├── api-gateway/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── filter/ │ │ │ │ └── AccessFilter.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ ├── eureka-server/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── Application.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ ├── service-A/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ ├── main/ │ │ │ │ ├── java/ │ │ │ │ │ └── com/ │ │ │ │ │ └── didispace/ │ │ │ │ │ ├── ComputeServiceApplication.java │ │ │ │ │ └── web/ │ │ │ │ │ └── ComputeController.java │ │ │ │ └── resources/ │ │ │ │ └── application.properties │ │ │ └── test/ │ │ │ └── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── ApplicationTests.java │ │ └── service-B/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── ComputeServiceApplication.java │ │ │ │ └── web/ │ │ │ │ └── ComputeController.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter9-2-1/ │ │ ├── compute-service/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ ├── main/ │ │ │ │ ├── java/ │ │ │ │ │ └── com/ │ │ │ │ │ └── didispace/ │ │ │ │ │ ├── Application.java │ │ │ │ │ └── service/ │ │ │ │ │ ├── ComputeService.java │ │ │ │ │ └── impl/ │ │ │ │ │ └── ComputeServiceImpl.java │ │ │ │ └── resources/ │ │ │ │ ├── application.properties │ │ │ │ └── dubbo.xml │ │ │ └── test/ │ │ │ └── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── ApplicationTests.java │ │ └── consumer/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ ├── Application.java │ │ │ │ └── service/ │ │ │ │ └── ComputeService.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── dubbo.xml │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── Chapter9-2-2/ │ │ ├── compute-service/ │ │ │ ├── compute-api/ │ │ │ │ ├── pom.xml │ │ │ │ └── src/ │ │ │ │ └── main/ │ │ │ │ └── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── service/ │ │ │ │ ├── ComputeService.java │ │ │ │ └── impl/ │ │ │ │ └── ComputeServiceImpl.java │ │ │ ├── compute-api-server/ │ │ │ │ ├── pom.xml │ │ │ │ └── src/ │ │ │ │ ├── main/ │ │ │ │ │ ├── java/ │ │ │ │ │ │ └── com/ │ │ │ │ │ │ └── didispace/ │ │ │ │ │ │ ├── Application.java │ │ │ │ │ │ └── service/ │ │ │ │ │ │ └── impl/ │ │ │ │ │ │ └── ComputeServiceImpl.java │ │ │ │ │ └── resources/ │ │ │ │ │ ├── application.properties │ │ │ │ │ └── dubbo.xml │ │ │ │ └── test/ │ │ │ │ └── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── ApplicationTests.java │ │ │ └── pom.xml │ │ └── consumer/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── Application.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── dubbo.xml │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── ApplicationTests.java │ ├── README.md │ └── README_zh.md ├── 2.x/ │ ├── README.md │ ├── README_zh.md │ ├── chapter1-1/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter11/ │ │ │ │ ├── Chapter11Application.java │ │ │ │ └── HelloController.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter11/ │ │ └── Chapter11ApplicationTests.java │ ├── chapter1-2/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter12/ │ │ │ └── Chapter12Application.java │ │ └── resources/ │ │ └── application.yaml │ ├── chapter1-3/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter13/ │ │ │ └── Chapter13Application.java │ │ └── resources/ │ │ └── application.yaml │ ├── chapter1-4/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter14/ │ │ │ ├── Chapter14Application.java │ │ │ ├── DidiProperties.java │ │ │ └── HelloController.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter1-5/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter15/ │ │ │ │ └── Chapter15Application.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter15/ │ │ └── PropertiesTest.java │ ├── chapter2-1/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter21/ │ │ │ │ ├── Chapter21Application.java │ │ │ │ ├── User.java │ │ │ │ └── UserController.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter21/ │ │ └── Chapter21ApplicationTests.java │ ├── chapter2-2/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter22/ │ │ │ ├── Chapter22Application.java │ │ │ ├── User.java │ │ │ └── UserController.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter2-3/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter23/ │ │ │ ├── Chapter23Application.java │ │ │ ├── User.java │ │ │ └── UserController.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter2-4/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter24/ │ │ │ ├── Chapter24Application.java │ │ │ ├── User.java │ │ │ └── UserController.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter2-5/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── docs/ │ │ │ ├── asciidoc/ │ │ │ │ ├── generated/ │ │ │ │ │ ├── definitions.adoc │ │ │ │ │ ├── overview.adoc │ │ │ │ │ ├── paths.adoc │ │ │ │ │ └── security.adoc │ │ │ │ ├── generated-by-plugin/ │ │ │ │ │ ├── definitions.adoc │ │ │ │ │ ├── overview.adoc │ │ │ │ │ ├── paths.adoc │ │ │ │ │ └── security.adoc │ │ │ │ └── html/ │ │ │ │ ├── definitions.html │ │ │ │ ├── overview.html │ │ │ │ ├── paths.html │ │ │ │ └── security.html │ │ │ ├── confluence/ │ │ │ │ └── generated/ │ │ │ │ ├── definitions.txt │ │ │ │ ├── overview.txt │ │ │ │ ├── paths.txt │ │ │ │ └── security.txt │ │ │ └── markdown/ │ │ │ └── generated/ │ │ │ ├── definitions.md │ │ │ ├── overview.md │ │ │ ├── paths.md │ │ │ └── security.md │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter25/ │ │ │ │ ├── Chapter25Application.java │ │ │ │ ├── User.java │ │ │ │ └── UserController.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter25/ │ │ └── DemoApplicationTests.java │ ├── chapter2-6/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter26/ │ │ │ ├── Chapter26Application.java │ │ │ ├── User.java │ │ │ └── UserController.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter2-7/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter27/ │ │ │ ├── Chapter27Application.java │ │ │ ├── User.java │ │ │ └── UserController.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter2-8/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter28/ │ │ │ ├── Chapter28Application.java │ │ │ ├── User.java │ │ │ └── UserController.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter2-9/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter29/ │ │ │ ├── Chapter29Application.java │ │ │ ├── User.java │ │ │ └── UserController.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter3-1/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter31/ │ │ │ │ ├── Chapter31Application.java │ │ │ │ ├── User.java │ │ │ │ ├── UserService.java │ │ │ │ └── UserServiceImpl.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter31/ │ │ └── Chapter31ApplicationTests.java │ ├── chapter3-10/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter310/ │ │ │ │ ├── Chapter310Application.java │ │ │ │ ├── User.java │ │ │ │ └── UserRepository.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter310/ │ │ └── Chapter310ApplicationTests.java │ ├── chapter3-11/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter311/ │ │ │ │ ├── Chapter311Application.java │ │ │ │ ├── User.java │ │ │ │ ├── UserService.java │ │ │ │ └── UserServiceImpl.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── db/ │ │ │ └── migration/ │ │ │ ├── V1_1__alter_table_user.sql │ │ │ └── V1__Base_version.sql │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter311/ │ │ └── Chapter311ApplicationTests.java │ ├── chapter3-12/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter312/ │ │ │ │ ├── Chapter312Application.java │ │ │ │ ├── DataSourceConfiguration.java │ │ │ │ └── TestService.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter312/ │ │ └── Chapter312ApplicationTests.java │ ├── chapter3-13/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter313/ │ │ │ │ └── Chapter313Application.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── schema-all.sql │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter31/ │ │ └── Chapter31ApplicationTests.java │ ├── chapter3-2/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter32/ │ │ │ │ ├── Chapter32Application.java │ │ │ │ ├── User.java │ │ │ │ ├── UserService.java │ │ │ │ └── UserServiceImpl.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter32/ │ │ └── Chapter32ApplicationTests.java │ ├── chapter3-3/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter33/ │ │ │ │ ├── Chapter33Application.java │ │ │ │ ├── User.java │ │ │ │ ├── UserController.java │ │ │ │ ├── UserService.java │ │ │ │ └── UserServiceImpl.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter33/ │ │ └── Chapter33ApplicationTests.java │ ├── chapter3-4/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter34/ │ │ │ │ ├── Chapter34Application.java │ │ │ │ ├── User.java │ │ │ │ └── UserRepository.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter34/ │ │ └── Chapter34ApplicationTests.java │ ├── chapter3-5/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter35/ │ │ │ │ ├── Chapter35Application.java │ │ │ │ ├── User.java │ │ │ │ └── UserMapper.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter35/ │ │ └── Chapter35ApplicationTests.java │ ├── chapter3-6/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter36/ │ │ │ │ ├── Chapter36Application.java │ │ │ │ ├── entity/ │ │ │ │ │ └── User.java │ │ │ │ └── mapper/ │ │ │ │ └── UserMapper.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── mapper/ │ │ │ └── UserMapper.xml │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter36/ │ │ └── Chapter36ApplicationTests.java │ ├── chapter3-7/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter37/ │ │ │ │ ├── Chapter37Application.java │ │ │ │ └── DataSourceConfiguration.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter37/ │ │ └── Chapter37ApplicationTests.java │ ├── chapter3-8/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter38/ │ │ │ │ ├── Chapter38Application.java │ │ │ │ ├── DataSourceConfiguration.java │ │ │ │ ├── PrimaryConfig.java │ │ │ │ ├── SecondaryConfig.java │ │ │ │ ├── p/ │ │ │ │ │ ├── User.java │ │ │ │ │ └── UserRepository.java │ │ │ │ └── s/ │ │ │ │ ├── Message.java │ │ │ │ └── MessageRepository.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter38/ │ │ └── Chapter38ApplicationTests.java │ ├── chapter3-9/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter39/ │ │ │ │ ├── Chapter39Application.java │ │ │ │ ├── DataSourceConfiguration.java │ │ │ │ ├── PrimaryConfig.java │ │ │ │ ├── SecondaryConfig.java │ │ │ │ ├── p/ │ │ │ │ │ ├── entity/ │ │ │ │ │ │ └── UserPrimary.java │ │ │ │ │ └── mapper/ │ │ │ │ │ └── UserMapperPrimary.java │ │ │ │ └── s/ │ │ │ │ ├── entity/ │ │ │ │ │ └── UserSecondary.java │ │ │ │ └── mapper/ │ │ │ │ └── UserMapperSecondary.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ ├── mapper.primary/ │ │ │ │ └── UserMapper.xml │ │ │ └── mapper.secondary/ │ │ │ └── UserMapper.xml │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter39/ │ │ └── Chapter39ApplicationTests.java │ ├── chapter4-1/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter41/ │ │ │ ├── Chapter41Application.java │ │ │ └── HelloController.java │ │ └── resources/ │ │ ├── application.properties │ │ └── templates/ │ │ └── index.html │ ├── chapter4-2/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter42/ │ │ │ ├── Chapter42Application.java │ │ │ └── HelloController.java │ │ └── resources/ │ │ ├── application.properties │ │ └── templates/ │ │ └── index.html │ ├── chapter4-3/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter43/ │ │ │ │ ├── Chapter43Application.java │ │ │ │ └── UploadController.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── templates/ │ │ │ └── upload.html │ │ └── test/ │ │ └── java/ │ │ └── FileTest.java │ ├── chapter4-4/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter44/ │ │ │ │ ├── Chapter44Application.java │ │ │ │ └── UploadController.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── templates/ │ │ │ └── upload.html │ │ └── test/ │ │ └── java/ │ │ └── FileTest.java │ ├── chapter4-5/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter45/ │ │ │ ├── Application.java │ │ │ ├── HelloController.java │ │ │ └── WebSecurityConfig.java │ │ └── resources/ │ │ ├── application.properties │ │ └── templates/ │ │ ├── hello.html │ │ ├── index.html │ │ └── login.html │ ├── chapter5-1/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter51/ │ │ │ │ ├── Chapter51Application.java │ │ │ │ ├── User.java │ │ │ │ └── UserRepository.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter51/ │ │ └── Chapter51ApplicationTests.java │ ├── chapter5-2/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter52/ │ │ │ │ ├── Chapter52Application.java │ │ │ │ ├── User.java │ │ │ │ └── UserRepository.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ └── ehcache.xml │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter52/ │ │ └── Chapter52ApplicationTests.java │ ├── chapter5-3/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter53/ │ │ │ │ ├── Chapter53Application.java │ │ │ │ ├── User.java │ │ │ │ └── UserRepository.java │ │ │ └── resources/ │ │ │ ├── application.properties │ │ │ ├── ehcache-1.xml │ │ │ └── ehcache-2.xml │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter53/ │ │ └── Chapter53ApplicationTests.java │ ├── chapter5-4/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter54/ │ │ │ │ ├── Chapter54Application.java │ │ │ │ ├── User.java │ │ │ │ └── UserRepository.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter54/ │ │ └── Chapter54ApplicationTests.java │ ├── chapter5-5/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter55/ │ │ │ └── Chapter55Application.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter6-1/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter61/ │ │ │ │ ├── Chapter61Application.java │ │ │ │ ├── User.java │ │ │ │ └── UserRepository.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter61/ │ │ └── ApplicationTests.java │ ├── chapter6-2/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter62/ │ │ │ │ ├── Chapter62Application.java │ │ │ │ ├── Person.java │ │ │ │ └── PersonRepository.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter62/ │ │ │ └── ApplicationTests.java │ │ └── resources/ │ │ ├── application.properties │ │ └── ldap-server.ldif │ ├── chapter6-3/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter63/ │ │ │ │ ├── Chapter63Application.java │ │ │ │ └── Monitor.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter63/ │ │ └── ApplicationTests.java │ ├── chapter6-4/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter64/ │ │ │ │ ├── Chapter64Application.java │ │ │ │ ├── UserInfo.java │ │ │ │ └── UserInfoRepository.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter64/ │ │ └── ApplicationTests.java │ ├── chapter7-1/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter71/ │ │ │ ├── Chapter71Application.java │ │ │ └── ScheduledTasks.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter7-2/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter72/ │ │ │ ├── Chapter72Application.java │ │ │ └── MySimpleJob.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter7-3/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter73/ │ │ │ ├── Chapter73Application.java │ │ │ └── MyShardingJob.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter7-4/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter74/ │ │ │ ├── Chapter74Application.java │ │ │ └── MySimpleJob.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter7-5/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter75/ │ │ │ │ ├── AsyncTasks.java │ │ │ │ └── Chapter75Application.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter75/ │ │ └── Chapter75ApplicationTests.java │ ├── chapter7-6/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter76/ │ │ │ │ ├── AsyncTasks.java │ │ │ │ └── Chapter76Application.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter76/ │ │ └── Chapter76ApplicationTests.java │ ├── chapter7-7/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter77/ │ │ │ │ ├── AsyncTasks.java │ │ │ │ └── Chapter77Application.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter77/ │ │ └── Chapter77ApplicationTests.java │ ├── chapter7-8/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── didispace/ │ │ │ │ └── chapter78/ │ │ │ │ ├── AsyncTasks.java │ │ │ │ └── Chapter78Application.java │ │ │ └── resources/ │ │ │ └── application.properties │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── didispace/ │ │ └── chapter78/ │ │ └── Chapter78ApplicationTests.java │ ├── chapter8-1/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter81/ │ │ │ └── Chapter81Application.java │ │ └── resources/ │ │ └── application.properties │ ├── chapter8-2/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter82/ │ │ │ └── Chapter82Application.java │ │ └── resources/ │ │ ├── application.properties │ │ └── log4j2.xml │ ├── chapter8-3/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── didispace/ │ │ │ └── chapter83/ │ │ │ └── Chapter83Application.java │ │ └── resources/ │ │ ├── application.properties │ │ └── tinylog.properties │ └── pom.xml ├── README.md ├── README_zh.md └── pom.xml
SYMBOL INDEX (1104 symbols across 375 files)
FILE: 1.x/Chapter1/src/main/java/com/didispace/Chapter1Application.java
class Chapter1Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter1/src/main/java/com/didispace/web/HelloController.java
class HelloController (line 6) | @RestController
method index (line 9) | @RequestMapping("/hello")
FILE: 1.x/Chapter1/src/test/java/com/didispace/Chapter1ApplicationTests.java
class Chapter1ApplicationTests (line 21) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 28) | @Before
method getHello (line 33) | @Test
FILE: 1.x/Chapter2-1-1/src/main/java/com/didispace/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) {
FILE: 1.x/Chapter2-1-1/src/main/java/com/didispace/service/BlogProperties.java
class BlogProperties (line 12) | @Component
method getName (line 33) | public String getName() {
method setName (line 37) | public void setName(String name) {
method getTitle (line 41) | public String getTitle() {
method setTitle (line 45) | public void setTitle(String title) {
method getDesc (line 49) | public String getDesc() {
method setDesc (line 53) | public void setDesc(String desc) {
method getValue (line 57) | public String getValue() {
method setValue (line 61) | public void setValue(String value) {
method getNumber (line 65) | public Integer getNumber() {
method setNumber (line 69) | public void setNumber(Integer number) {
method getBignumber (line 73) | public Long getBignumber() {
method setBignumber (line 77) | public void setBignumber(Long bignumber) {
method getTest1 (line 81) | public Integer getTest1() {
method setTest1 (line 85) | public void setTest1(Integer test1) {
method getTest2 (line 89) | public Integer getTest2() {
method setTest2 (line 93) | public void setTest2(Integer test2) {
FILE: 1.x/Chapter2-1-1/src/main/java/com/didispace/web/HelloController.java
class HelloController (line 13) | @RestController
method index (line 16) | @RequestMapping("/hello")
FILE: 1.x/Chapter2-1-1/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 23) | @RunWith(SpringJUnit4ClassRunner.class)
method test1 (line 33) | @Test
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/Application.java
class Application (line 9) | @Slf4j
method main (line 13) | public static void main(String[] args) {
method dataLoader (line 17) | @Bean
class DataLoader (line 22) | @Slf4j
method run (line 25) | @Override
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationEnvironmentPreparedEventListener.java
class ApplicationEnvironmentPreparedEventListener (line 7) | @Slf4j
method onApplicationEvent (line 10) | @Override
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationFailedEventListener.java
class ApplicationFailedEventListener (line 7) | @Slf4j
method onApplicationEvent (line 10) | @Override
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationPreparedEventListener.java
class ApplicationPreparedEventListener (line 7) | @Slf4j
method onApplicationEvent (line 10) | @Override
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationReadyEventListener.java
class ApplicationReadyEventListener (line 7) | @Slf4j
method onApplicationEvent (line 10) | @Override
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationStartedEventListener.java
class ApplicationStartedEventListener (line 8) | @Slf4j
method onApplicationEvent (line 11) | @Override
FILE: 1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationStartingEventListener.java
class ApplicationStartingEventListener (line 7) | @Slf4j
method onApplicationEvent (line 10) | @Override
FILE: 1.x/Chapter2-2-1/src/main/java/com/didispace/Application.java
class Application (line 19) | @SpringBootApplication
method main (line 22) | public static void main(String[] args) {
FILE: 1.x/Chapter2-2-1/src/main/java/com/didispace/FooProperties.java
class FooProperties (line 6) | @Data
FILE: 1.x/Chapter2-2-1/src/main/java/com/didispace/PostInfo.java
class PostInfo (line 6) | @Data
FILE: 1.x/Chapter3-1-1/src/main/java/com/didispace/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) {
FILE: 1.x/Chapter3-1-1/src/main/java/com/didispace/domain/User.java
class User (line 12) | public class User {
method getId (line 18) | public Long getId() {
method setId (line 22) | public void setId(Long id) {
method getName (line 26) | public String getName() {
method setName (line 30) | public void setName(String name) {
method getAge (line 34) | public Integer getAge() {
method setAge (line 38) | public void setAge(Integer age) {
FILE: 1.x/Chapter3-1-1/src/main/java/com/didispace/web/HelloController.java
class HelloController (line 13) | @RestController
method index (line 16) | @RequestMapping("/hello")
FILE: 1.x/Chapter3-1-1/src/main/java/com/didispace/web/UserController.java
class UserController (line 16) | @RestController
method getUserList (line 22) | @RequestMapping(value="/", method=RequestMethod.GET)
method postUser (line 30) | @RequestMapping(value="/", method=RequestMethod.POST)
method getUser (line 38) | @RequestMapping(value="/{id}", method=RequestMethod.GET)
method putUser (line 45) | @RequestMapping(value="/{id}", method=RequestMethod.PUT)
method deleteUser (line 55) | @RequestMapping(value="/{id}", method=RequestMethod.DELETE)
FILE: 1.x/Chapter3-1-1/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 32) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 39) | @Before
method getHello (line 46) | @Test
method testUserController (line 53) | @Test
FILE: 1.x/Chapter3-1-2/src/main/java/com/didispace/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) {
FILE: 1.x/Chapter3-1-2/src/main/java/com/didispace/web/HelloController.java
class HelloController (line 15) | @Controller
method hello (line 18) | @ResponseBody
method index (line 24) | @RequestMapping("/")
FILE: 1.x/Chapter3-1-2/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 28) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 35) | @Before
method getHello (line 41) | @Test
FILE: 1.x/Chapter3-1-3/src/main/java/com/didispace/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) {
FILE: 1.x/Chapter3-1-3/src/main/java/com/didispace/web/HelloController.java
class HelloController (line 15) | @Controller
method hello (line 18) | @RequestMapping("/hello")
method index (line 24) | @RequestMapping("/")
FILE: 1.x/Chapter3-1-3/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 28) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 35) | @Before
method getHello (line 41) | @Test
FILE: 1.x/Chapter3-1-4/src/main/java/com/didispace/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) {
FILE: 1.x/Chapter3-1-4/src/main/java/com/didispace/web/HelloController.java
class HelloController (line 15) | @Controller
method hello (line 18) | @RequestMapping("/hello")
method index (line 24) | @RequestMapping("/")
FILE: 1.x/Chapter3-1-4/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 28) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 35) | @Before
method getHello (line 41) | @Test
FILE: 1.x/Chapter3-1-5/src/main/java/com/didispace/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) {
FILE: 1.x/Chapter3-1-5/src/main/java/com/didispace/Swagger2.java
class Swagger2 (line 19) | @Configuration
method createRestApi (line 23) | @Bean
method apiInfo (line 33) | private ApiInfo apiInfo() {
FILE: 1.x/Chapter3-1-5/src/main/java/com/didispace/domain/User.java
class User (line 12) | public class User {
method getId (line 18) | public Long getId() {
method setId (line 22) | public void setId(Long id) {
method getName (line 26) | public String getName() {
method setName (line 30) | public void setName(String name) {
method getAge (line 34) | public Integer getAge() {
method setAge (line 38) | public void setAge(Integer age) {
FILE: 1.x/Chapter3-1-5/src/main/java/com/didispace/web/HelloController.java
class HelloController (line 15) | @RestController
method index (line 18) | @ApiIgnore
FILE: 1.x/Chapter3-1-5/src/main/java/com/didispace/web/UserController.java
class UserController (line 17) | @RestController
method getUserList (line 23) | @ApiOperation(value="获取用户列表", notes="")
method postUser (line 30) | @ApiOperation(value="创建用户", notes="根据User对象创建用户")
method getUser (line 38) | @ApiOperation(value="获取用户详细信息", notes="根据url的id来获取用户详细信息")
method putUser (line 45) | @ApiOperation(value="更新用户详细信息", notes="根据url的id来指定更新对象,并根据传过来的user信息来更...
method deleteUser (line 59) | @ApiOperation(value="删除用户", notes="根据url的id来指定删除对象")
FILE: 1.x/Chapter3-1-6/src/main/java/com/didispace/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) {
FILE: 1.x/Chapter3-1-6/src/main/java/com/didispace/dto/ErrorInfo.java
class ErrorInfo (line 3) | public class ErrorInfo<T> {
method getUrl (line 13) | public String getUrl() {
method setUrl (line 17) | public void setUrl(String url) {
method getOK (line 21) | public static Integer getOK() {
method getERROR (line 25) | public static Integer getERROR() {
method getCode (line 29) | public Integer getCode() {
method setCode (line 33) | public void setCode(Integer code) {
method getMessage (line 37) | public String getMessage() {
method setMessage (line 41) | public void setMessage(String message) {
method getData (line 45) | public T getData() {
method setData (line 49) | public void setData(T data) {
FILE: 1.x/Chapter3-1-6/src/main/java/com/didispace/exception/GlobalExceptionHandler.java
class GlobalExceptionHandler (line 11) | @ControllerAdvice
method defaultErrorHandler (line 14) | @ExceptionHandler(value = Exception.class)
method jsonErrorHandler (line 23) | @ExceptionHandler(value = MyException.class)
FILE: 1.x/Chapter3-1-6/src/main/java/com/didispace/exception/MyException.java
class MyException (line 9) | public class MyException extends Exception {
method MyException (line 11) | public MyException(String message) {
FILE: 1.x/Chapter3-1-6/src/main/java/com/didispace/web/HelloController.java
class HelloController (line 16) | @Controller
method hello (line 19) | @RequestMapping("/hello")
method json (line 24) | @RequestMapping("/json")
method index (line 29) | @RequestMapping("/")
FILE: 1.x/Chapter3-1-6/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 28) | @RunWith(SpringJUnit4ClassRunner.class)
FILE: 1.x/Chapter3-1-7/src/main/java/com/didispace/Application.java
class Application (line 23) | @SpringBootApplication
method main (line 26) | public static void main(String[] args) {
class HelloController (line 30) | @RestController
method user (line 33) | @PostMapping("/user")
class UserDto (line 40) | @Data
method serializingObjectMapper (line 50) | @Bean
FILE: 1.x/Chapter3-1-8/src/main/java/com/didispace/Application.java
class Application (line 11) | @SpringBootApplication
method main (line 14) | public static void main(String[] args) {
FILE: 1.x/Chapter3-1-8/src/main/java/com/didispace/web/User.java
class User (line 15) | @Data
FILE: 1.x/Chapter3-1-8/src/main/java/com/didispace/web/UserController.java
class UserController (line 14) | @Controller
method create (line 17) | @PostMapping(value = "/user", consumes = MediaType.APPLICATION_XML_VAL...
FILE: 1.x/Chapter3-2-1/src/main/java/com/didispace/Application.java
class Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter3-2-1/src/main/java/com/didispace/service/UserService.java
type UserService (line 9) | public interface UserService {
method create (line 16) | void create(String name, Integer age);
method deleteByName (line 22) | void deleteByName(String name);
method getAllUsers (line 27) | Integer getAllUsers();
method deleteAllUsers (line 32) | void deleteAllUsers();
FILE: 1.x/Chapter3-2-1/src/main/java/com/didispace/service/UserServiceImpl.java
class UserServiceImpl (line 13) | @Service
method create (line 19) | @Override
method deleteByName (line 24) | @Override
method getAllUsers (line 29) | @Override
method deleteAllUsers (line 34) | @Override
FILE: 1.x/Chapter3-2-1/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 13) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 20) | @Before
method test (line 26) | @Test
FILE: 1.x/Chapter3-2-10/src/main/java/com/didispace/Application.java
class Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter3-2-10/src/main/java/com/didispace/Person.java
class Person (line 8) | @Entry(base = "ou=people,dc=didispace,dc=com", objectClasses = "inetOrgP...
FILE: 1.x/Chapter3-2-10/src/main/java/com/didispace/PersonRepository.java
type PersonRepository (line 7) | public interface PersonRepository extends CrudRepository<Person, Name> {
FILE: 1.x/Chapter3-2-10/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 9) | @RunWith(SpringRunner.class)
method findAll (line 16) | @Test
method save (line 25) | @Test
FILE: 1.x/Chapter3-2-11/src/main/java/com/didispace/Application.java
class Application (line 7) | @EnableMongoPlus
method main (line 11) | public static void main(String[] args) {
FILE: 1.x/Chapter3-2-11/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 12) | @RunWith(SpringRunner.class)
method test (line 20) | @Test
FILE: 1.x/Chapter3-2-2/src/main/java/com/didispace/Application.java
class Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter3-2-2/src/main/java/com/didispace/domain/User.java
class User (line 14) | @Entity
method User (line 27) | public User(){}
method User (line 29) | public User(String name, Integer age) {
method getId (line 34) | public Long getId() {
method setId (line 38) | public void setId(Long id) {
method getName (line 42) | public String getName() {
method setName (line 46) | public void setName(String name) {
method getAge (line 50) | public Integer getAge() {
method setAge (line 54) | public void setAge(Integer age) {
FILE: 1.x/Chapter3-2-2/src/main/java/com/didispace/domain/UserRepository.java
type UserRepository (line 14) | public interface UserRepository extends JpaRepository<User, Long> {
method findByName (line 16) | User findByName(String name);
method findByNameAndAge (line 18) | User findByNameAndAge(String name, Integer age);
method findUser (line 20) | @Query("from User u where u.name=:name")
FILE: 1.x/Chapter3-2-2/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 13) | @RunWith(SpringJUnit4ClassRunner.class)
method test (line 20) | @Test
FILE: 1.x/Chapter3-2-3/src/main/java/com/didispace/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) {
FILE: 1.x/Chapter3-2-3/src/main/java/com/didispace/DataSourceConfig.java
class DataSourceConfig (line 19) | @Configuration
method primaryDataSource (line 22) | @Bean(name = "primaryDataSource")
method secondaryDataSource (line 29) | @Bean(name = "secondaryDataSource")
method primaryJdbcTemplate (line 37) | @Bean(name = "primaryJdbcTemplate")
method secondaryJdbcTemplate (line 43) | @Bean(name = "secondaryJdbcTemplate")
FILE: 1.x/Chapter3-2-3/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 14) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 26) | @Before
method test (line 32) | @Test
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) {
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/DataSourceConfig.java
class DataSourceConfig (line 18) | @Configuration
method primaryDataSource (line 21) | @Bean(name = "primaryDataSource")
method secondaryDataSource (line 28) | @Bean(name = "secondaryDataSource")
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/PrimaryConfig.java
class PrimaryConfig (line 20) | @Configuration
method entityManager (line 31) | @Primary
method entityManagerFactoryPrimary (line 37) | @Primary
method getVendorProperties (line 51) | private Map<String, String> getVendorProperties(DataSource dataSource) {
method transactionManagerPrimary (line 55) | @Primary
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/SecondaryConfig.java
class SecondaryConfig (line 19) | @Configuration
method entityManager (line 30) | @Bean(name = "entityManagerSecondary")
method entityManagerFactorySecondary (line 35) | @Bean(name = "entityManagerFactorySecondary")
method getVendorProperties (line 48) | private Map<String, String> getVendorProperties(DataSource dataSource) {
method transactionManagerSecondary (line 52) | @Bean(name = "transactionManagerSecondary")
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/domain/p/User.java
class User (line 14) | @Entity
method User (line 27) | public User(){}
method User (line 29) | public User(String name, Integer age) {
method getId (line 34) | public Long getId() {
method setId (line 38) | public void setId(Long id) {
method getName (line 42) | public String getName() {
method setName (line 46) | public void setName(String name) {
method getAge (line 50) | public Integer getAge() {
method setAge (line 54) | public void setAge(Integer age) {
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/domain/p/UserRepository.java
type UserRepository (line 14) | public interface UserRepository extends JpaRepository<User, Long> {
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/domain/s/Message.java
class Message (line 14) | @Entity
method Message (line 27) | public Message(){}
method Message (line 29) | public Message(String name, String content) {
method getId (line 34) | public Long getId() {
method setId (line 38) | public void setId(Long id) {
method getName (line 42) | public String getName() {
method setName (line 46) | public void setName(String name) {
method getContent (line 50) | public String getContent() {
method setContent (line 54) | public void setContent(String content) {
FILE: 1.x/Chapter3-2-4/src/main/java/com/didispace/domain/s/MessageRepository.java
type MessageRepository (line 12) | public interface MessageRepository extends JpaRepository<Message, Long> {
FILE: 1.x/Chapter3-2-4/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 16) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 25) | @Before
method test (line 29) | @Test
FILE: 1.x/Chapter3-2-5/src/main/java/com/didispace/Application.java
class Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter3-2-5/src/main/java/com/didispace/RedisConfig.java
class RedisConfig (line 17) | @Configuration
method jedisConnectionFactory (line 20) | @Bean
method redisTemplate (line 25) | @Bean
FILE: 1.x/Chapter3-2-5/src/main/java/com/didispace/RedisObjectSerializer.java
class RedisObjectSerializer (line 9) | public class RedisObjectSerializer implements RedisSerializer<Object> {
method deserialize (line 16) | public Object deserialize(byte[] bytes) {
method serialize (line 28) | public byte[] serialize(Object object) {
method isEmpty (line 40) | private boolean isEmpty(byte[] data) {
FILE: 1.x/Chapter3-2-5/src/main/java/com/didispace/domain/User.java
class User (line 11) | public class User implements Serializable {
method User (line 18) | public User(String username, Integer age) {
method getUsername (line 23) | public String getUsername() {
method setUsername (line 27) | public void setUsername(String username) {
method getAge (line 31) | public Integer getAge() {
method setAge (line 35) | public void setAge(Integer age) {
FILE: 1.x/Chapter3-2-5/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 15) | @RunWith(SpringJUnit4ClassRunner.class)
method test (line 25) | @Test
FILE: 1.x/Chapter3-2-6/src/main/java/com/didispace/Application.java
class Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter3-2-6/src/main/java/com/didispace/domain/User.java
class User (line 11) | public class User {
method User (line 19) | public User(Long id, String username, Integer age) {
method getId (line 25) | public Long getId() {
method setId (line 29) | public void setId(Long id) {
method getUsername (line 33) | public String getUsername() {
method setUsername (line 37) | public void setUsername(String username) {
method getAge (line 41) | public Integer getAge() {
method setAge (line 45) | public void setAge(Integer age) {
FILE: 1.x/Chapter3-2-6/src/main/java/com/didispace/domain/UserRepository.java
type UserRepository (line 11) | public interface UserRepository extends MongoRepository<User, Long> {
method findByUsername (line 13) | User findByUsername(String username);
FILE: 1.x/Chapter3-2-6/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 14) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 21) | @Before
method test (line 26) | @Test
FILE: 1.x/Chapter3-2-7/src/main/java/com/didispace/Application.java
class Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter3-2-7/src/main/java/com/didispace/domain/User.java
class User (line 3) | public class User {
method getId (line 9) | public Long getId() {
method setId (line 13) | public void setId(Long id) {
method getName (line 17) | public String getName() {
method setName (line 21) | public void setName(String name) {
method getAge (line 25) | public Integer getAge() {
method setAge (line 29) | public void setAge(Integer age) {
FILE: 1.x/Chapter3-2-7/src/main/java/com/didispace/domain/UserMapper.java
type UserMapper (line 5) | @Mapper
method findByName (line 8) | @Select("SELECT * FROM USER WHERE NAME = #{name}")
method insert (line 11) | @Insert("INSERT INTO USER(NAME, AGE) VALUES(#{name}, #{age})")
FILE: 1.x/Chapter3-2-7/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 15) | @RunWith(SpringJUnit4ClassRunner.class)
method findByName (line 23) | @Test
FILE: 1.x/Chapter3-2-8/src/main/java/com/didispace/Application.java
class Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter3-2-8/src/main/java/com/didispace/domain/User.java
class User (line 3) | public class User {
method User (line 9) | public User() {
method User (line 12) | public User(Long id, String name, Integer age) {
method User (line 18) | public User(String name, Integer age) {
method getId (line 23) | public Long getId() {
method setId (line 27) | public void setId(Long id) {
method getName (line 31) | public String getName() {
method setName (line 35) | public void setName(String name) {
method getAge (line 39) | public Integer getAge() {
method setAge (line 43) | public void setAge(Integer age) {
FILE: 1.x/Chapter3-2-8/src/main/java/com/didispace/domain/UserMapper.java
type UserMapper (line 8) | @Mapper
method findByName (line 11) | @Select("SELECT * FROM user WHERE name = #{name}")
method findAll (line 14) | @Results({
method insert (line 21) | @Insert("INSERT INTO user(name, age) VALUES(#{name}, #{age})")
method update (line 24) | @Update("UPDATE user SET age=#{age} WHERE name=#{name}")
method delete (line 27) | @Delete("DELETE FROM user WHERE id =#{id}")
method insertByUser (line 30) | @Insert("INSERT INTO user(name, age) VALUES(#{name}, #{age})")
method insertByMap (line 33) | @Insert("INSERT INTO user(name, age) VALUES(#{name,jdbcType=VARCHAR}, ...
FILE: 1.x/Chapter3-2-8/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 20) | @RunWith(SpringJUnit4ClassRunner.class)
method testUserMapper (line 28) | @Test
FILE: 1.x/Chapter3-2-9/src/main/java/com/didispace/Application.java
class Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter3-2-9/src/main/java/com/didispace/service/UserService.java
type UserService (line 9) | public interface UserService {
method create (line 16) | void create(String name, Integer age);
method deleteByName (line 22) | void deleteByName(String name);
method getAllUsers (line 27) | Integer getAllUsers();
method deleteAllUsers (line 32) | void deleteAllUsers();
FILE: 1.x/Chapter3-2-9/src/main/java/com/didispace/service/UserServiceImpl.java
class UserServiceImpl (line 13) | @Service
method create (line 19) | @Override
method deleteByName (line 24) | @Override
method getAllUsers (line 29) | @Override
method deleteAllUsers (line 34) | @Override
FILE: 1.x/Chapter3-2-9/src/main/resources/db/V1__Base_version.sql
type `user` (line 4) | CREATE TABLE `user` (
FILE: 1.x/Chapter3-2-9/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 13) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 20) | @Before
method test (line 26) | @Test
FILE: 1.x/Chapter3-3-1/src/main/java/com/didispace/Application.java
class Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter3-3-1/src/main/java/com/didispace/domain/User.java
class User (line 14) | @Entity
method User (line 27) | public User(){}
method User (line 29) | public User(String name, Integer age) {
method getId (line 34) | public Long getId() {
method setId (line 38) | public void setId(Long id) {
method getName (line 42) | public String getName() {
method setName (line 46) | public void setName(String name) {
method getAge (line 50) | public Integer getAge() {
method setAge (line 54) | public void setAge(Integer age) {
FILE: 1.x/Chapter3-3-1/src/main/java/com/didispace/domain/UserRepository.java
type UserRepository (line 14) | public interface UserRepository extends JpaRepository<User, Long> {
method findByName (line 16) | User findByName(String name);
method findByNameAndAge (line 18) | User findByNameAndAge(String name, Integer age);
method findUser (line 20) | @Query("from User u where u.name=:name")
FILE: 1.x/Chapter3-3-1/src/main/java/com/didispace/service/UserService.java
type UserService (line 12) | public interface UserService {
method login (line 14) | @Transactional(isolation = Isolation.DEFAULT, propagation = Propagatio...
FILE: 1.x/Chapter3-3-1/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 14) | @RunWith(SpringJUnit4ClassRunner.class)
method test (line 21) | @Test
FILE: 1.x/Chapter4-1-1/src/main/java/com/didispace/Application.java
class Application (line 7) | @SpringBootApplication
method main (line 11) | public static void main(String[] args) {
FILE: 1.x/Chapter4-1-1/src/main/java/com/didispace/task/ScheduledTasks.java
class ScheduledTasks (line 9) | @Component
method reportCurrentTime (line 14) | @Scheduled(fixedRate = 5000)
FILE: 1.x/Chapter4-1-1/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 9) | @RunWith(SpringJUnit4ClassRunner.class)
method getHello (line 14) | @Test
FILE: 1.x/Chapter4-1-2/src/main/java/com/didispace/Application.java
class Application (line 8) | @SpringBootApplication
method main (line 12) | public static void main(String[] args) {
FILE: 1.x/Chapter4-1-2/src/main/java/com/didispace/async/Task.java
class Task (line 16) | @Component
method doTaskOne (line 21) | @Async
method doTaskTwo (line 31) | @Async
method doTaskThree (line 41) | @Async
FILE: 1.x/Chapter4-1-2/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 13) | @RunWith(SpringJUnit4ClassRunner.class)
method test (line 20) | @Test
FILE: 1.x/Chapter4-1-3/src/main/java/com/didispace/Application.java
class Application (line 14) | @SpringBootApplication
method main (line 17) | public static void main(String[] args) {
class TaskPoolConfig (line 21) | @EnableAsync
method taskExecutor (line 25) | @Bean("taskExecutor")
FILE: 1.x/Chapter4-1-3/src/main/java/com/didispace/async/Task.java
class Task (line 15) | @Slf4j
method doTaskOne (line 21) | @Async("taskExecutor")
method doTaskTwo (line 30) | @Async("taskExecutor")
method doTaskThree (line 39) | @Async("taskExecutor")
FILE: 1.x/Chapter4-1-3/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 11) | @RunWith(SpringJUnit4ClassRunner.class)
method test (line 18) | @Test
FILE: 1.x/Chapter4-1-4/src/main/java/com/didispace/Application.java
class Application (line 12) | @SpringBootApplication
method main (line 15) | public static void main(String[] args) {
class TaskPoolConfig (line 19) | @EnableAsync
method taskExecutor (line 23) | @Bean("taskExecutor")
FILE: 1.x/Chapter4-1-4/src/main/java/com/didispace/async/Task.java
class Task (line 15) | @Slf4j
method doTaskOne (line 22) | @Async("taskExecutor")
method doTaskTwo (line 31) | @Async("taskExecutor")
method doTaskThree (line 40) | @Async("taskExecutor")
FILE: 1.x/Chapter4-1-4/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 12) | @RunWith(SpringJUnit4ClassRunner.class)
method test (line 19) | @Test
FILE: 1.x/Chapter4-1-5/src/main/java/com/didispace/Application.java
class Application (line 14) | @SpringBootApplication
method main (line 17) | public static void main(String[] args) {
class TaskPoolConfig (line 21) | @EnableAsync
method taskExecutor (line 25) | @Bean("taskExecutor")
FILE: 1.x/Chapter4-1-5/src/main/java/com/didispace/async/Task.java
class Task (line 17) | @Slf4j
method run (line 23) | @Async("taskExecutor")
FILE: 1.x/Chapter4-1-5/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 14) | @Slf4j
method test (line 22) | @Test
FILE: 1.x/Chapter4-2-2/src/main/java/com/didispace/Application.java
class Application (line 9) | @SpringBootApplication
method main (line 12) | public static void main(String[] args) {
FILE: 1.x/Chapter4-2-2/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 10) | @RunWith(SpringJUnit4ClassRunner.class)
method test (line 16) | @Test
FILE: 1.x/Chapter4-2-3/src/main/java/com/didispace/Application.java
class Application (line 9) | @SpringBootApplication
method main (line 12) | public static void main(String[] args) {
FILE: 1.x/Chapter4-2-3/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 10) | @RunWith(SpringJUnit4ClassRunner.class)
method test (line 16) | @Test
FILE: 1.x/Chapter4-2-4/src/main/java/com/didispace/Application.java
class Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter4-2-4/src/main/java/com/didispace/aspect/WebLogAspect.java
class WebLogAspect (line 25) | @Aspect
method webLog (line 34) | @Pointcut("execution(public * com.didispace.web..*.*(..))")
method doBefore (line 37) | @Before("webLog()")
method doAfterReturning (line 54) | @AfterReturning(returning = "ret", pointcut = "webLog()")
FILE: 1.x/Chapter4-2-4/src/main/java/com/didispace/web/HelloController.java
class HelloController (line 11) | @RestController
method hello (line 14) | @RequestMapping(value = "/hello", method = RequestMethod.GET)
FILE: 1.x/Chapter4-2-4/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 10) | @RunWith(SpringJUnit4ClassRunner.class)
method test (line 16) | @Test
FILE: 1.x/Chapter4-2-5/src/main/java/com/didispace/Application.java
class Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter4-2-5/src/main/java/com/didispace/aspect/WebLogAspect.java
class WebLogAspect (line 28) | @Aspect
method webLog (line 35) | @Pointcut("execution(public * com.didispace.web..*.*(..))")
method doBefore (line 38) | @Before("webLog()")
method getBasicDBObject (line 49) | private BasicDBObject getBasicDBObject(HttpServletRequest request, Joi...
method getHeadersInfo (line 74) | private Map<String, String> getHeadersInfo(HttpServletRequest request) {
FILE: 1.x/Chapter4-2-5/src/main/java/com/didispace/log/MongoAppender.java
class MongoAppender (line 19) | public class MongoAppender extends AppenderSkeleton {
method append (line 29) | @Override
method close (line 42) | @Override
method requiresLayout (line 49) | @Override
method getConnectionUrl (line 54) | public String getConnectionUrl() {
method setConnectionUrl (line 58) | public void setConnectionUrl(String connectionUrl) {
method getDatabaseName (line 62) | public String getDatabaseName() {
method setDatabaseName (line 66) | public void setDatabaseName(String databaseName) {
method getCollectionName (line 70) | public String getCollectionName() {
method setCollectionName (line 74) | public void setCollectionName(String collectionName) {
FILE: 1.x/Chapter4-2-5/src/main/java/com/didispace/web/HelloController.java
class HelloController (line 11) | @RestController
method hello (line 14) | @RequestMapping(value = "/hello", method = RequestMethod.GET)
FILE: 1.x/Chapter4-2-5/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 10) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 14) | @Before
method getHello (line 20) | @Test
FILE: 1.x/Chapter4-2-6/src/main/java/com/didispace/DemoApplication.java
class DemoApplication (line 11) | @RestController
method testLogLevel (line 17) | @RequestMapping(value = "/test", method = RequestMethod.GET)
method main (line 25) | public static void main(String[] args) {
FILE: 1.x/Chapter4-2-6/src/test/java/com/didispace/DemoApplicationTests.java
class DemoApplicationTests (line 8) | @RunWith(SpringRunner.class)
method contextLoads (line 12) | @Test
FILE: 1.x/Chapter4-3-1/src/main/java/com/didispace/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) {
FILE: 1.x/Chapter4-3-1/src/main/java/com/didispace/WebSecurityConfig.java
class WebSecurityConfig (line 10) | @Configuration
method configure (line 14) | @Override
method configureGlobal (line 29) | @Autowired
FILE: 1.x/Chapter4-3-1/src/main/java/com/didispace/web/HelloController.java
class HelloController (line 15) | @Controller
method index (line 18) | @RequestMapping("/")
method hello (line 23) | @RequestMapping("/hello")
method login (line 28) | @RequestMapping(value = "/login", method = RequestMethod.GET)
FILE: 1.x/Chapter4-3-1/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 28) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 35) | @Before
method getHello (line 41) | @Test
FILE: 1.x/Chapter4-4-1/src/main/java/com/didispace/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 17) | public static void main(String[] args) {
FILE: 1.x/Chapter4-4-1/src/main/java/com/didispace/domain/User.java
class User (line 14) | @Entity
method User (line 27) | public User(){}
method User (line 29) | public User(String name, Integer age) {
method getId (line 34) | public Long getId() {
method setId (line 38) | public void setId(Long id) {
method getName (line 42) | public String getName() {
method setName (line 46) | public void setName(String name) {
method getAge (line 50) | public Integer getAge() {
method setAge (line 54) | public void setAge(Integer age) {
FILE: 1.x/Chapter4-4-1/src/main/java/com/didispace/domain/UserRepository.java
type UserRepository (line 16) | @CacheConfig(cacheNames = "users")
method findByName (line 19) | @Cacheable(key = "#p0", condition = "#p0.length() < 10")
FILE: 1.x/Chapter4-4-1/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 20) | @RunWith(SpringJUnit4ClassRunner.class)
method before (line 30) | @Before
method test (line 35) | @Test
FILE: 1.x/Chapter4-4-2/src/main/java/com/didispace/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 17) | public static void main(String[] args) {
FILE: 1.x/Chapter4-4-2/src/main/java/com/didispace/domain/User.java
class User (line 15) | @Entity
method User (line 28) | public User(){}
method User (line 30) | public User(String name, Integer age) {
method getId (line 35) | public Long getId() {
method setId (line 39) | public void setId(Long id) {
method getName (line 43) | public String getName() {
method setName (line 47) | public void setName(String name) {
method getAge (line 51) | public Integer getAge() {
method setAge (line 55) | public void setAge(Integer age) {
FILE: 1.x/Chapter4-4-2/src/main/java/com/didispace/domain/UserRepository.java
type UserRepository (line 15) | @CacheConfig(cacheNames = "users")
method findByName (line 18) | @Cacheable(key = "#p0")
method save (line 21) | @CachePut(key = "#p0.name")
FILE: 1.x/Chapter4-4-2/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 19) | @RunWith(SpringJUnit4ClassRunner.class)
method before (line 29) | @Before
method test (line 34) | @Test
FILE: 1.x/Chapter4-5-1/src/main/java/com/didispace/Application.java
class Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter4-5-1/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 21) | @RunWith(SpringJUnit4ClassRunner.class)
method sendSimpleMail (line 30) | @Test
method sendAttachmentsMail (line 42) | @Test
method sendInlineMail (line 60) | @Test
method sendTemplateMail (line 77) | @Test
FILE: 1.x/Chapter5-2-1/src/main/java/com/didispace/HelloApplication.java
class HelloApplication (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter5-2-1/src/main/java/com/didispace/rabbit/RabbitConfig.java
class RabbitConfig (line 12) | @Configuration
method helloQueue (line 15) | @Bean
FILE: 1.x/Chapter5-2-1/src/main/java/com/didispace/rabbit/Receiver.java
class Receiver (line 15) | @Component
method process (line 19) | @RabbitHandler
FILE: 1.x/Chapter5-2-1/src/main/java/com/didispace/rabbit/Sender.java
class Sender (line 10) | @Component
method send (line 16) | public void send() {
FILE: 1.x/Chapter5-2-1/src/test/java/com/didispace/HelloApplicationTests.java
class HelloApplicationTests (line 10) | @RunWith(SpringJUnit4ClassRunner.class)
method hello (line 17) | @Test
FILE: 1.x/Chapter6-1-1/src/main/java/com/didispace/Application.java
class Application (line 9) | @SpringBootApplication
method main (line 12) | public static void main(String[] args) {
method run (line 19) | @Override
FILE: 1.x/Chapter6-1-1/src/main/java/com/didispace/EventConfig.java
class EventConfig (line 10) | @WithStateMachine
method create (line 15) | @OnTransition(target = "UNPAID")
method pay (line 20) | @OnTransition(source = "UNPAID", target = "WAITING_FOR_RECEIVE")
method payStart (line 25) | @OnTransitionStart(source = "UNPAID", target = "WAITING_FOR_RECEIVE")
method payEnd (line 30) | @OnTransitionEnd(source = "UNPAID", target = "WAITING_FOR_RECEIVE")
method receive (line 35) | @OnTransition(source = "WAITING_FOR_RECEIVE", target = "DONE")
FILE: 1.x/Chapter6-1-1/src/main/java/com/didispace/Events.java
type Events (line 3) | public enum Events {
FILE: 1.x/Chapter6-1-1/src/main/java/com/didispace/StateMachineConfig.java
class StateMachineConfig (line 19) | @Configuration
method configure (line 25) | @Override
method configure (line 34) | @Override
FILE: 1.x/Chapter6-1-1/src/main/java/com/didispace/States.java
type States (line 3) | public enum States {
FILE: 1.x/Chapter6-2-1/src/main/java/com/didispace/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) {
FILE: 1.x/Chapter6-2-1/src/main/java/com/didispace/web/HelloController.java
class HelloController (line 13) | @RestController
method index (line 16) | @RequestMapping("/hello")
FILE: 1.x/Chapter6-2-1/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 14) | @SpringBootTest
method test1 (line 17) | @Test
FILE: 1.x/Chapter9-1-1/compute-service/src/main/java/com/didispace/ComputeServiceApplication.java
class ComputeServiceApplication (line 7) | @EnableDiscoveryClient
method main (line 11) | public static void main(String[] args) {
FILE: 1.x/Chapter9-1-1/compute-service/src/main/java/com/didispace/web/ComputeController.java
class ComputeController (line 12) | @RestController
method add (line 20) | @RequestMapping(value = "/add" ,method = RequestMethod.GET)
FILE: 1.x/Chapter9-1-1/compute-service/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 21) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 28) | @Before
method getHello (line 33) | @Test
FILE: 1.x/Chapter9-1-1/eureka-server/src/main/java/com/didispace/Application.java
class Application (line 7) | @EnableEurekaServer
method main (line 11) | public static void main(String[] args) {
FILE: 1.x/Chapter9-1-2/eureka-feign/src/main/java/com/didispace/FeignApplication.java
class FeignApplication (line 8) | @SpringBootApplication
method main (line 13) | public static void main(String[] args) {
FILE: 1.x/Chapter9-1-2/eureka-feign/src/main/java/com/didispace/service/ComputeClient.java
type ComputeClient (line 8) | @FeignClient("compute-service")
method add (line 11) | @RequestMapping(method = RequestMethod.GET, value = "/add")
FILE: 1.x/Chapter9-1-2/eureka-feign/src/main/java/com/didispace/web/ConsumerController.java
class ConsumerController (line 9) | @RestController
method add (line 15) | @RequestMapping(value = "/add", method = RequestMethod.GET)
FILE: 1.x/Chapter9-1-2/eureka-ribbon/src/main/java/com/didispace/RibbonApplication.java
class RibbonApplication (line 10) | @SpringBootApplication
method restTemplate (line 14) | @Bean
method main (line 20) | public static void main(String[] args) {
FILE: 1.x/Chapter9-1-2/eureka-ribbon/src/main/java/com/didispace/web/ConsumerController.java
class ConsumerController (line 9) | @RestController
method add (line 15) | @RequestMapping(value = "/add", method = RequestMethod.GET)
FILE: 1.x/Chapter9-1-3/compute-service/src/main/java/com/didispace/ComputeServiceApplication.java
class ComputeServiceApplication (line 7) | @EnableDiscoveryClient
method main (line 11) | public static void main(String[] args) {
FILE: 1.x/Chapter9-1-3/compute-service/src/main/java/com/didispace/web/ComputeController.java
class ComputeController (line 12) | @RestController
method add (line 20) | @RequestMapping(value = "/add" ,method = RequestMethod.GET)
FILE: 1.x/Chapter9-1-3/compute-service/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 21) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 28) | @Before
method getHello (line 33) | @Test
FILE: 1.x/Chapter9-1-3/eureka-feign/src/main/java/com/didispace/FeignApplication.java
class FeignApplication (line 8) | @SpringBootApplication
method main (line 13) | public static void main(String[] args) {
FILE: 1.x/Chapter9-1-3/eureka-feign/src/main/java/com/didispace/service/ComputeClient.java
type ComputeClient (line 8) | @FeignClient(value = "compute-service", fallback = ComputeClientHystrix....
method add (line 11) | @RequestMapping(method = RequestMethod.GET, value = "/add")
FILE: 1.x/Chapter9-1-3/eureka-feign/src/main/java/com/didispace/service/ComputeClientHystrix.java
class ComputeClientHystrix (line 6) | @Component
method add (line 9) | @Override
FILE: 1.x/Chapter9-1-3/eureka-feign/src/main/java/com/didispace/web/ConsumerController.java
class ConsumerController (line 9) | @RestController
method add (line 15) | @RequestMapping(value = "/add", method = RequestMethod.GET)
FILE: 1.x/Chapter9-1-3/eureka-ribbon/src/main/java/com/didispace/RibbonApplication.java
class RibbonApplication (line 11) | @SpringBootApplication
method restTemplate (line 16) | @Bean
method main (line 22) | public static void main(String[] args) {
FILE: 1.x/Chapter9-1-3/eureka-ribbon/src/main/java/com/didispace/service/ComputeService.java
class ComputeService (line 8) | @Service
method addService (line 14) | @HystrixCommand(fallbackMethod = "addServiceFallback")
method addServiceFallback (line 19) | public String addServiceFallback() {
FILE: 1.x/Chapter9-1-3/eureka-ribbon/src/main/java/com/didispace/web/ConsumerController.java
class ConsumerController (line 13) | @RestController
method add (line 19) | @RequestMapping(value = "/add", method = RequestMethod.GET)
FILE: 1.x/Chapter9-1-3/eureka-server/src/main/java/com/didispace/Application.java
class Application (line 7) | @EnableEurekaServer
method main (line 11) | public static void main(String[] args) {
FILE: 1.x/Chapter9-1-4/config-client/src/main/java/com/didispace/Application.java
class Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 1.x/Chapter9-1-4/config-client/src/main/java/com/didispace/web/TestController.java
class TestController (line 8) | @RefreshScope
method from (line 15) | @RequestMapping("/from")
method setFrom (line 21) | public void setFrom(String from) {
method getFrom (line 25) | public String getFrom() {
FILE: 1.x/Chapter9-1-4/config-server/src/main/java/com/didispace/Application.java
class Application (line 7) | @EnableConfigServer
method main (line 11) | public static void main(String[] args) {
FILE: 1.x/Chapter9-1-5/api-gateway/src/main/java/com/didispace/Application.java
class Application (line 9) | @EnableZuulProxy
method main (line 13) | public static void main(String[] args) {
method accessFilter (line 17) | @Bean
FILE: 1.x/Chapter9-1-5/api-gateway/src/main/java/com/didispace/filter/AccessFilter.java
class AccessFilter (line 10) | public class AccessFilter extends ZuulFilter {
method filterType (line 14) | @Override
method filterOrder (line 19) | @Override
method shouldFilter (line 24) | @Override
method run (line 29) | @Override
FILE: 1.x/Chapter9-1-5/eureka-server/src/main/java/com/didispace/Application.java
class Application (line 7) | @EnableEurekaServer
method main (line 11) | public static void main(String[] args) {
FILE: 1.x/Chapter9-1-5/service-A/src/main/java/com/didispace/ComputeServiceApplication.java
class ComputeServiceApplication (line 7) | @EnableDiscoveryClient
method main (line 11) | public static void main(String[] args) {
FILE: 1.x/Chapter9-1-5/service-A/src/main/java/com/didispace/web/ComputeController.java
class ComputeController (line 12) | @RestController
method add (line 20) | @RequestMapping(value = "/add" ,method = RequestMethod.GET)
FILE: 1.x/Chapter9-1-5/service-A/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 21) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 28) | @Before
method getHello (line 33) | @Test
FILE: 1.x/Chapter9-1-5/service-B/src/main/java/com/didispace/ComputeServiceApplication.java
class ComputeServiceApplication (line 7) | @EnableDiscoveryClient
method main (line 11) | public static void main(String[] args) {
FILE: 1.x/Chapter9-1-5/service-B/src/main/java/com/didispace/web/ComputeController.java
class ComputeController (line 12) | @RestController
method add (line 20) | @RequestMapping(value = "/add" ,method = RequestMethod.GET)
FILE: 1.x/Chapter9-1-5/service-B/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 15) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 22) | @Before
method getHello (line 27) | @Test
FILE: 1.x/Chapter9-2-1/compute-service/src/main/java/com/didispace/Application.java
class Application (line 12) | @SpringBootApplication
method closeLatch (line 18) | @Bean
method main (line 23) | public static void main(String[] args) throws InterruptedException {
FILE: 1.x/Chapter9-2-1/compute-service/src/main/java/com/didispace/service/ComputeService.java
type ComputeService (line 6) | public interface ComputeService {
method add (line 8) | Integer add(int a, int b);
FILE: 1.x/Chapter9-2-1/compute-service/src/main/java/com/didispace/service/impl/ComputeServiceImpl.java
class ComputeServiceImpl (line 8) | public class ComputeServiceImpl implements ComputeService {
method add (line 10) | @Override
FILE: 1.x/Chapter9-2-1/compute-service/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 10) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 14) | @Before
method getHello (line 18) | @Test
FILE: 1.x/Chapter9-2-1/consumer/src/main/java/com/didispace/Application.java
class Application (line 12) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) throws InterruptedException {
FILE: 1.x/Chapter9-2-1/consumer/src/main/java/com/didispace/service/ComputeService.java
type ComputeService (line 6) | public interface ComputeService {
method add (line 8) | Integer add(int a, int b);
FILE: 1.x/Chapter9-2-1/consumer/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 12) | @RunWith(SpringJUnit4ClassRunner.class)
method testAdd (line 19) | @Test
FILE: 1.x/Chapter9-2-2/compute-service/compute-api-server/src/main/java/com/didispace/Application.java
class Application (line 12) | @SpringBootApplication
method closeLatch (line 18) | @Bean
method main (line 23) | public static void main(String[] args) throws InterruptedException {
FILE: 1.x/Chapter9-2-2/compute-service/compute-api-server/src/main/java/com/didispace/service/impl/ComputeServiceImpl.java
class ComputeServiceImpl (line 8) | public class ComputeServiceImpl implements ComputeService {
method add (line 10) | @Override
FILE: 1.x/Chapter9-2-2/compute-service/compute-api-server/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 10) | @RunWith(SpringJUnit4ClassRunner.class)
method setUp (line 14) | @Before
method getHello (line 18) | @Test
FILE: 1.x/Chapter9-2-2/compute-service/compute-api/src/main/java/com/didispace/service/ComputeService.java
type ComputeService (line 6) | public interface ComputeService {
method add (line 8) | Integer add(int a, int b);
FILE: 1.x/Chapter9-2-2/compute-service/compute-api/src/main/java/com/didispace/service/impl/ComputeServiceImpl.java
class ComputeServiceImpl (line 8) | public class ComputeServiceImpl implements ComputeService {
method add (line 10) | @Override
FILE: 1.x/Chapter9-2-2/consumer/src/main/java/com/didispace/Application.java
class Application (line 7) | @SpringBootApplication
method main (line 11) | public static void main(String[] args) throws InterruptedException {
FILE: 1.x/Chapter9-2-2/consumer/src/test/java/com/didispace/ApplicationTests.java
class ApplicationTests (line 12) | @RunWith(SpringJUnit4ClassRunner.class)
method testAdd (line 19) | @Test
FILE: 2.x/chapter1-1/src/main/java/com/didispace/chapter11/Chapter11Application.java
class Chapter11Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter1-1/src/main/java/com/didispace/chapter11/HelloController.java
class HelloController (line 6) | @RestController
method index (line 9) | @RequestMapping("/hello")
FILE: 2.x/chapter1-1/src/test/java/com/didispace/chapter11/Chapter11ApplicationTests.java
class Chapter11ApplicationTests (line 16) | @SpringBootTest
method setUp (line 21) | @Before
method getHello (line 26) | @Test
FILE: 2.x/chapter1-2/src/main/java/com/didispace/chapter12/Chapter12Application.java
class Chapter12Application (line 9) | @SpringBootApplication
method main (line 12) | public static void main(String[] args) {
class HelloController (line 16) | @RestController
method index (line 22) | @RequestMapping("/")
FILE: 2.x/chapter1-3/src/main/java/com/didispace/chapter13/Chapter13Application.java
class Chapter13Application (line 11) | @SpringBootApplication
method main (line 14) | public static void main(String[] args) {
class HelloController (line 18) | @Slf4j
method index (line 28) | @RequestMapping("/")
FILE: 2.x/chapter1-4/src/main/java/com/didispace/chapter14/Chapter14Application.java
class Chapter14Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter1-4/src/main/java/com/didispace/chapter14/DidiProperties.java
class DidiProperties (line 7) | @Data
FILE: 2.x/chapter1-4/src/main/java/com/didispace/chapter14/HelloController.java
class HelloController (line 6) | @RestController
method index (line 9) | @RequestMapping("/hello")
FILE: 2.x/chapter1-5/src/main/java/com/didispace/chapter15/Chapter15Application.java
class Chapter15Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter1-5/src/test/java/com/didispace/chapter15/PropertiesTest.java
class PropertiesTest (line 9) | @Slf4j
method test (line 16) | @Test
FILE: 2.x/chapter2-1/src/main/java/com/didispace/chapter21/Chapter21Application.java
class Chapter21Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter2-1/src/main/java/com/didispace/chapter21/User.java
class User (line 5) | @Data
FILE: 2.x/chapter2-1/src/main/java/com/didispace/chapter21/UserController.java
class UserController (line 7) | @RestController
method getUserList (line 19) | @GetMapping("/")
method postUser (line 32) | @PostMapping("/")
method getUser (line 45) | @GetMapping("/{id}")
method putUser (line 58) | @PutMapping("/{id}")
method deleteUser (line 73) | @DeleteMapping("/{id}")
FILE: 2.x/chapter2-1/src/test/java/com/didispace/chapter21/Chapter21ApplicationTests.java
class Chapter21ApplicationTests (line 19) | @RunWith(SpringRunner.class)
method setUp (line 25) | @Before
method testUserController (line 30) | @Test
FILE: 2.x/chapter2-2/src/main/java/com/didispace/chapter22/Chapter22Application.java
class Chapter22Application (line 7) | @EnableSwagger2Doc
method main (line 11) | public static void main(String[] args) {
FILE: 2.x/chapter2-2/src/main/java/com/didispace/chapter22/User.java
class User (line 7) | @Data
FILE: 2.x/chapter2-2/src/main/java/com/didispace/chapter22/UserController.java
class UserController (line 10) | @Api(tags = "用户管理")
method getUserList (line 18) | @GetMapping("/")
method postUser (line 25) | @PostMapping("/")
method getUser (line 32) | @GetMapping("/{id}")
method putUser (line 38) | @PutMapping("/{id}")
method deleteUser (line 49) | @DeleteMapping("/{id}")
FILE: 2.x/chapter2-3/src/main/java/com/didispace/chapter23/Chapter23Application.java
class Chapter23Application (line 7) | @EnableSwagger2Doc
method main (line 11) | public static void main(String[] args) {
FILE: 2.x/chapter2-3/src/main/java/com/didispace/chapter23/User.java
class User (line 9) | @Data
FILE: 2.x/chapter2-3/src/main/java/com/didispace/chapter23/UserController.java
class UserController (line 11) | @Api(tags = "用户管理")
method getUserList (line 19) | @GetMapping("/")
method postUser (line 26) | @PostMapping("/")
method getUser (line 33) | @GetMapping("/{id}")
method putUser (line 39) | @PutMapping("/{id}")
method deleteUser (line 50) | @DeleteMapping("/{id}")
FILE: 2.x/chapter2-4/src/main/java/com/didispace/chapter24/Chapter24Application.java
class Chapter24Application (line 15) | @EnableSwagger2Doc
method main (line 19) | public static void main(String[] args) {
class TeacherController (line 23) | @Api(tags = {"1-教师管理","3-教学管理"})
method xxx (line 28) | @ApiOperation(value = "xxx")
class StudentController (line 36) | @Api(tags = {"2-学生管理"})
method bbb (line 41) | @ApiOperation(value = "获取学生清单", tags = "3-教学管理")
method ccc (line 47) | @ApiOperation("获取教某个学生的老师清单")
method aaa (line 53) | @ApiOperation("创建一个学生")
FILE: 2.x/chapter2-4/src/main/java/com/didispace/chapter24/User.java
class User (line 9) | @Data
FILE: 2.x/chapter2-4/src/main/java/com/didispace/chapter24/UserController.java
class UserController (line 11) | @Api(tags = "用户管理")
method getUserList (line 19) | @GetMapping("/")
method postUser (line 26) | @PostMapping("/")
method getUser (line 33) | @GetMapping("/{id}")
method putUser (line 39) | @PutMapping("/{id}")
method deleteUser (line 50) | @DeleteMapping("/{id}")
FILE: 2.x/chapter2-5/src/main/java/com/didispace/chapter25/Chapter25Application.java
class Chapter25Application (line 7) | @EnableSwagger2Doc
method main (line 11) | public static void main(String[] args) {
FILE: 2.x/chapter2-5/src/main/java/com/didispace/chapter25/User.java
class User (line 7) | @Data
FILE: 2.x/chapter2-5/src/main/java/com/didispace/chapter25/UserController.java
class UserController (line 10) | @Api(tags = "用户管理")
method getUserList (line 18) | @GetMapping("/")
method postUser (line 25) | @PostMapping("/")
method getUser (line 32) | @GetMapping("/{id}")
method putUser (line 38) | @PutMapping("/{id}")
method deleteUser (line 49) | @DeleteMapping("/{id}")
FILE: 2.x/chapter2-5/src/test/java/com/didispace/chapter25/DemoApplicationTests.java
class DemoApplicationTests (line 16) | @RunWith(SpringRunner.class)
method generateAsciiDocs (line 20) | @Test
method generateMarkdownDocs (line 37) | @Test
method generateConfluenceDocs (line 54) | @Test
FILE: 2.x/chapter2-6/src/main/java/com/didispace/chapter26/Chapter26Application.java
class Chapter26Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter2-6/src/main/java/com/didispace/chapter26/User.java
class User (line 5) | @Data
FILE: 2.x/chapter2-6/src/main/java/com/didispace/chapter26/UserController.java
class UserController (line 7) | @RestController
method getUserList (line 14) | @GetMapping("/")
method postUser (line 20) | @PostMapping("/")
method getUser (line 26) | @GetMapping("/{id}")
method putUser (line 31) | @PutMapping("/{id}")
method deleteUser (line 40) | @DeleteMapping("/{id}")
FILE: 2.x/chapter2-7/src/main/java/com/didispace/chapter27/Chapter27Application.java
class Chapter27Application (line 7) | @EnableOpenApi
method main (line 11) | public static void main(String[] args) {
FILE: 2.x/chapter2-7/src/main/java/com/didispace/chapter27/User.java
class User (line 11) | @Data
FILE: 2.x/chapter2-7/src/main/java/com/didispace/chapter27/UserController.java
class UserController (line 13) | @Api(tags="用户管理")
method create (line 17) | @ApiOperation("创建用户")
method findById (line 23) | @ApiOperation("用户详情")
method list (line 29) | @ApiOperation("用户列表")
method deleteById (line 39) | @ApiIgnore
FILE: 2.x/chapter2-8/src/main/java/com/didispace/chapter28/Chapter28Application.java
class Chapter28Application (line 11) | @SpringBootApplication
method main (line 14) | public static void main(String[] args) {
FILE: 2.x/chapter2-8/src/main/java/com/didispace/chapter28/User.java
class User (line 15) | @Data
FILE: 2.x/chapter2-8/src/main/java/com/didispace/chapter28/UserController.java
class UserController (line 14) | @Controller
method create (line 17) | @PostMapping(value = "/user",
FILE: 2.x/chapter2-9/src/main/java/com/didispace/chapter29/Chapter29Application.java
class Chapter29Application (line 11) | @SpringBootApplication
method main (line 14) | public static void main(String[] args) {
FILE: 2.x/chapter2-9/src/main/java/com/didispace/chapter29/User.java
class User (line 15) | @Data
FILE: 2.x/chapter2-9/src/main/java/com/didispace/chapter29/UserController.java
class UserController (line 14) | @Controller
method create (line 17) | @PostMapping(value = "/user",
FILE: 2.x/chapter3-1/src/main/java/com/didispace/chapter31/Chapter31Application.java
class Chapter31Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter3-1/src/main/java/com/didispace/chapter31/User.java
class User (line 6) | @Data
FILE: 2.x/chapter3-1/src/main/java/com/didispace/chapter31/UserService.java
type UserService (line 5) | public interface UserService {
method create (line 13) | int create(String name, Integer age);
method getByName (line 21) | List<User> getByName(String name);
method deleteByName (line 28) | int deleteByName(String name);
method getAllUsers (line 33) | int getAllUsers();
method deleteAllUsers (line 38) | int deleteAllUsers();
FILE: 2.x/chapter3-1/src/main/java/com/didispace/chapter31/UserServiceImpl.java
class UserServiceImpl (line 12) | @Service
method UserServiceImpl (line 17) | UserServiceImpl(JdbcTemplate jdbcTemplate) {
method create (line 21) | @Override
method getByName (line 26) | @Override
method deleteByName (line 37) | @Override
method getAllUsers (line 42) | @Override
method deleteAllUsers (line 47) | @Override
FILE: 2.x/chapter3-1/src/test/java/com/didispace/chapter31/Chapter31ApplicationTests.java
class Chapter31ApplicationTests (line 25) | @RunWith(SpringRunner.class)
method setUp (line 32) | @Before
method test (line 38) | @Test
FILE: 2.x/chapter3-10/src/main/java/com/didispace/chapter310/Chapter310Application.java
class Chapter310Application (line 8) | @SpringBootApplication
method main (line 11) | public static void main(String[] args) {
class TextController (line 15) | @RestController
method hello (line 18) | @GetMapping("/hello")
FILE: 2.x/chapter3-10/src/main/java/com/didispace/chapter310/User.java
class User (line 9) | @Entity
method User (line 22) | public User(String name, Integer age) {
FILE: 2.x/chapter3-10/src/main/java/com/didispace/chapter310/UserRepository.java
type UserRepository (line 13) | public interface UserRepository extends JpaRepository<User, Long> {
method findByName (line 15) | User findByName(String name);
method findByNameAndAge (line 17) | User findByNameAndAge(String name, Integer age);
method findUser (line 19) | @Query("from User u where u.name=:name")
FILE: 2.x/chapter3-10/src/test/java/com/didispace/chapter310/Chapter310ApplicationTests.java
class Chapter310ApplicationTests (line 13) | @Slf4j
method test (line 21) | @Test
FILE: 2.x/chapter3-11/src/main/java/com/didispace/chapter311/Chapter311Application.java
class Chapter311Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter3-11/src/main/java/com/didispace/chapter311/User.java
class User (line 6) | @Data
FILE: 2.x/chapter3-11/src/main/java/com/didispace/chapter311/UserService.java
type UserService (line 5) | public interface UserService {
method create (line 13) | int create(String name, Integer age);
method getByName (line 21) | List<User> getByName(String name);
method deleteByName (line 28) | int deleteByName(String name);
method getAllUsers (line 33) | int getAllUsers();
method deleteAllUsers (line 38) | int deleteAllUsers();
FILE: 2.x/chapter3-11/src/main/java/com/didispace/chapter311/UserServiceImpl.java
class UserServiceImpl (line 8) | @Service
method UserServiceImpl (line 13) | UserServiceImpl(JdbcTemplate jdbcTemplate) {
method create (line 17) | @Override
method getByName (line 22) | @Override
method deleteByName (line 34) | @Override
method getAllUsers (line 39) | @Override
method deleteAllUsers (line 44) | @Override
FILE: 2.x/chapter3-11/src/main/resources/db/migration/V1__Base_version.sql
type `user` (line 2) | CREATE TABLE `user` (
FILE: 2.x/chapter3-11/src/test/java/com/didispace/chapter311/Chapter311ApplicationTests.java
class Chapter311ApplicationTests (line 11) | @Slf4j
method test (line 18) | @Test
FILE: 2.x/chapter3-12/src/main/java/com/didispace/chapter312/Chapter312Application.java
class Chapter312Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter3-12/src/main/java/com/didispace/chapter312/DataSourceConfiguration.java
class DataSourceConfiguration (line 14) | @Configuration
method primaryDataSource (line 17) | @Primary
method secondaryDataSource (line 24) | @Bean
method primaryJdbcTemplate (line 30) | @Bean
method secondaryJdbcTemplate (line 35) | @Bean
FILE: 2.x/chapter3-12/src/main/java/com/didispace/chapter312/TestService.java
class TestService (line 7) | @Service
method TestService (line 13) | public TestService(JdbcTemplate primaryJdbcTemplate, JdbcTemplate seco...
method tx (line 18) | @Transactional
method tx2 (line 26) | @Transactional
FILE: 2.x/chapter3-12/src/test/java/com/didispace/chapter312/Chapter312ApplicationTests.java
class Chapter312ApplicationTests (line 12) | @SpringBootTest(classes = Chapter312Application.class)
method test1 (line 23) | @Test
method test2 (line 31) | @Test
FILE: 2.x/chapter3-13/src/main/java/com/didispace/chapter313/Chapter313Application.java
class Chapter313Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter3-13/src/main/resources/schema-all.sql
type test (line 1) | create table test.user_info
FILE: 2.x/chapter3-13/src/test/java/com/didispace/chapter31/Chapter31ApplicationTests.java
class Chapter31ApplicationTests (line 7) | @SpringBootTest
method test (line 11) | @Test
FILE: 2.x/chapter3-2/src/main/java/com/didispace/chapter32/Chapter32Application.java
class Chapter32Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter3-2/src/main/java/com/didispace/chapter32/User.java
class User (line 6) | @Data
FILE: 2.x/chapter3-2/src/main/java/com/didispace/chapter32/UserService.java
type UserService (line 5) | public interface UserService {
method create (line 13) | int create(String name, Integer age);
method getByName (line 21) | List<User> getByName(String name);
method deleteByName (line 28) | int deleteByName(String name);
method getAllUsers (line 33) | int getAllUsers();
method deleteAllUsers (line 38) | int deleteAllUsers();
FILE: 2.x/chapter3-2/src/main/java/com/didispace/chapter32/UserServiceImpl.java
class UserServiceImpl (line 12) | @Service
method UserServiceImpl (line 17) | UserServiceImpl(JdbcTemplate jdbcTemplate) {
method create (line 21) | @Override
method getByName (line 26) | @Override
method deleteByName (line 37) | @Override
method getAllUsers (line 42) | @Override
method deleteAllUsers (line 47) | @Override
FILE: 2.x/chapter3-2/src/test/java/com/didispace/chapter32/Chapter32ApplicationTests.java
class Chapter32ApplicationTests (line 26) | @Slf4j
method setUp (line 37) | @Before
method test (line 44) | @Test
FILE: 2.x/chapter3-3/src/main/java/com/didispace/chapter33/Chapter33Application.java
class Chapter33Application (line 8) | @SpringBootApplication
method main (line 11) | public static void main(String[] args) {
class TextController (line 15) | @RestController
method hello (line 18) | @GetMapping("/hello")
FILE: 2.x/chapter3-3/src/main/java/com/didispace/chapter33/User.java
class User (line 6) | @Data
FILE: 2.x/chapter3-3/src/main/java/com/didispace/chapter33/UserController.java
class UserController (line 15) | @Data
method create (line 22) | @PostMapping("/user")
method getByName (line 27) | @GetMapping("/user/{name}")
method deleteByName (line 32) | @DeleteMapping("/user/{name}")
method getAllUsers (line 37) | @GetMapping("/user/count")
method deleteAllUsers (line 42) | @DeleteMapping("/user/all")
FILE: 2.x/chapter3-3/src/main/java/com/didispace/chapter33/UserService.java
type UserService (line 5) | public interface UserService {
method create (line 13) | int create(String name, Integer age);
method getByName (line 21) | List<User> getByName(String name);
method deleteByName (line 28) | int deleteByName(String name);
method getAllUsers (line 33) | int getAllUsers();
method deleteAllUsers (line 38) | int deleteAllUsers();
FILE: 2.x/chapter3-3/src/main/java/com/didispace/chapter33/UserServiceImpl.java
class UserServiceImpl (line 12) | @Service
method UserServiceImpl (line 17) | UserServiceImpl(JdbcTemplate jdbcTemplate) {
method create (line 21) | @Override
method getByName (line 26) | @Override
method deleteByName (line 37) | @Override
method getAllUsers (line 42) | @Override
method deleteAllUsers (line 47) | @Override
FILE: 2.x/chapter3-3/src/test/java/com/didispace/chapter33/Chapter33ApplicationTests.java
class Chapter33ApplicationTests (line 26) | @Slf4j
method setUp (line 37) | @Before
method test (line 44) | @Test
FILE: 2.x/chapter3-4/src/main/java/com/didispace/chapter34/Chapter34Application.java
class Chapter34Application (line 8) | @SpringBootApplication
method main (line 11) | public static void main(String[] args) {
class TextController (line 15) | @RestController
method hello (line 18) | @GetMapping("/hello")
FILE: 2.x/chapter3-4/src/main/java/com/didispace/chapter34/User.java
class User (line 10) | @Entity
method User (line 22) | public User(String name, Integer age) {
FILE: 2.x/chapter3-4/src/main/java/com/didispace/chapter34/UserRepository.java
type UserRepository (line 13) | public interface UserRepository extends JpaRepository<User, Long> {
method findByName (line 15) | User findByName(String name);
method findByNameAndAge (line 17) | User findByNameAndAge(String name, Integer age);
method findUser (line 19) | @Query("from User u where u.name=:name")
FILE: 2.x/chapter3-4/src/test/java/com/didispace/chapter34/Chapter34ApplicationTests.java
class Chapter34ApplicationTests (line 15) | @Slf4j
method test (line 23) | @Test
FILE: 2.x/chapter3-5/src/main/java/com/didispace/chapter35/Chapter35Application.java
class Chapter35Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter3-5/src/main/java/com/didispace/chapter35/User.java
class User (line 7) | @Data
method User (line 16) | public User(String name, Integer age) {
FILE: 2.x/chapter3-5/src/main/java/com/didispace/chapter35/UserMapper.java
type UserMapper (line 14) | @Mapper
method findByName (line 17) | @Select("SELECT * FROM USER WHERE NAME = #{name}")
method insert (line 20) | @Insert("INSERT INTO USER(NAME, AGE) VALUES(#{name}, #{age})")
FILE: 2.x/chapter3-5/src/test/java/com/didispace/chapter35/Chapter35ApplicationTests.java
class Chapter35ApplicationTests (line 17) | @RunWith(SpringRunner.class)
method test (line 25) | @Test
FILE: 2.x/chapter3-6/src/main/java/com/didispace/chapter36/Chapter36Application.java
class Chapter36Application (line 7) | @MapperScan("com.didispace.chapter36.mapper")
method main (line 11) | public static void main(String[] args) {
FILE: 2.x/chapter3-6/src/main/java/com/didispace/chapter36/entity/User.java
class User (line 7) | @Data
method User (line 16) | public User(String name, Integer age) {
FILE: 2.x/chapter3-6/src/main/java/com/didispace/chapter36/mapper/UserMapper.java
type UserMapper (line 12) | public interface UserMapper {
method findByName (line 14) | User findByName(@Param("name") String name);
method insert (line 16) | int insert(@Param("name") String name, @Param("age") Integer age);
FILE: 2.x/chapter3-6/src/test/java/com/didispace/chapter36/Chapter36ApplicationTests.java
class Chapter36ApplicationTests (line 15) | @Slf4j
method test (line 24) | @Test
FILE: 2.x/chapter3-7/src/main/java/com/didispace/chapter37/Chapter37Application.java
class Chapter37Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter3-7/src/main/java/com/didispace/chapter37/DataSourceConfiguration.java
class DataSourceConfiguration (line 13) | @Configuration
method primaryDataSource (line 16) | @Primary
method secondaryDataSource (line 23) | @Bean
method primaryJdbcTemplate (line 29) | @Bean
method secondaryJdbcTemplate (line 34) | @Bean
FILE: 2.x/chapter3-7/src/test/java/com/didispace/chapter37/Chapter37ApplicationTests.java
class Chapter37ApplicationTests (line 14) | @RunWith(SpringRunner.class)
method setUp (line 24) | @Before
method test (line 30) | @Test
FILE: 2.x/chapter3-8/src/main/java/com/didispace/chapter38/Chapter38Application.java
class Chapter38Application (line 8) | @SpringBootApplication
method main (line 11) | public static void main(String[] args) {
FILE: 2.x/chapter3-8/src/main/java/com/didispace/chapter38/DataSourceConfiguration.java
class DataSourceConfiguration (line 13) | @Configuration
method primaryDataSource (line 16) | @Primary
method secondaryDataSource (line 23) | @Bean
FILE: 2.x/chapter3-8/src/main/java/com/didispace/chapter38/PrimaryConfig.java
class PrimaryConfig (line 23) | @Configuration
method getVendorProperties (line 40) | private Map<String, Object> getVendorProperties() {
method entityManager (line 44) | @Primary
method entityManagerFactoryPrimary (line 50) | @Primary
method transactionManagerPrimary (line 63) | @Primary
FILE: 2.x/chapter3-8/src/main/java/com/didispace/chapter38/SecondaryConfig.java
class SecondaryConfig (line 21) | @Configuration
method getVendorProperties (line 38) | private Map<String, Object> getVendorProperties() {
method entityManager (line 42) | @Bean(name = "entityManagerSecondary")
method entityManagerFactorySecondary (line 47) | @Bean(name = "entityManagerFactorySecondary")
method transactionManagerSecondary (line 57) | @Bean(name = "transactionManagerSecondary")
FILE: 2.x/chapter3-8/src/main/java/com/didispace/chapter38/p/User.java
class User (line 11) | @Entity
method User (line 23) | public User(String name, Integer age) {
FILE: 2.x/chapter3-8/src/main/java/com/didispace/chapter38/p/UserRepository.java
type UserRepository (line 13) | public interface UserRepository extends JpaRepository<User, Long> {
FILE: 2.x/chapter3-8/src/main/java/com/didispace/chapter38/s/Message.java
class Message (line 12) | @Entity
method Message (line 24) | public Message(String title, String message) {
FILE: 2.x/chapter3-8/src/main/java/com/didispace/chapter38/s/MessageRepository.java
type MessageRepository (line 11) | public interface MessageRepository extends JpaRepository<Message, Long> {
FILE: 2.x/chapter3-8/src/test/java/com/didispace/chapter38/Chapter38ApplicationTests.java
class Chapter38ApplicationTests (line 15) | @Slf4j
method test (line 25) | @Test
FILE: 2.x/chapter3-9/src/main/java/com/didispace/chapter39/Chapter39Application.java
class Chapter39Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter3-9/src/main/java/com/didispace/chapter39/DataSourceConfiguration.java
class DataSourceConfiguration (line 11) | @Configuration
method primaryDataSource (line 14) | @Primary
method secondaryDataSource (line 21) | @Bean
FILE: 2.x/chapter3-9/src/main/java/com/didispace/chapter39/PrimaryConfig.java
class PrimaryConfig (line 13) | @Configuration
method PrimaryConfig (line 22) | public PrimaryConfig(@Qualifier("primaryDataSource") DataSource primar...
method sqlSessionFactoryPrimary (line 26) | @Bean
method sqlSessionTemplatePrimary (line 33) | @Bean
FILE: 2.x/chapter3-9/src/main/java/com/didispace/chapter39/SecondaryConfig.java
class SecondaryConfig (line 13) | @Configuration
method SecondaryConfig (line 22) | public SecondaryConfig(@Qualifier("secondaryDataSource") DataSource se...
method sqlSessionFactorySecondary (line 26) | @Bean
method sqlSessionTemplateSecondary (line 33) | @Bean
FILE: 2.x/chapter3-9/src/main/java/com/didispace/chapter39/p/entity/UserPrimary.java
class UserPrimary (line 7) | @Data
method UserPrimary (line 16) | public UserPrimary(String name, Integer age) {
FILE: 2.x/chapter3-9/src/main/java/com/didispace/chapter39/p/mapper/UserMapperPrimary.java
type UserMapperPrimary (line 15) | public interface UserMapperPrimary {
method findByName (line 17) | @Select("SELECT * FROM USER WHERE NAME = #{name}")
method insert (line 20) | @Insert("INSERT INTO USER(NAME, AGE) VALUES(#{name}, #{age})")
method deleteAll (line 23) | @Delete("DELETE FROM USER")
FILE: 2.x/chapter3-9/src/main/java/com/didispace/chapter39/s/entity/UserSecondary.java
class UserSecondary (line 7) | @Data
method UserSecondary (line 16) | public UserSecondary(String name, Integer age) {
FILE: 2.x/chapter3-9/src/main/java/com/didispace/chapter39/s/mapper/UserMapperSecondary.java
type UserMapperSecondary (line 15) | public interface UserMapperSecondary {
method findByName (line 17) | @Select("SELECT * FROM USER WHERE NAME = #{name}")
method insert (line 20) | @Insert("INSERT INTO USER(NAME, AGE) VALUES(#{name}, #{age})")
method deleteAll (line 23) | @Delete("DELETE FROM USER")
FILE: 2.x/chapter3-9/src/test/java/com/didispace/chapter39/Chapter39ApplicationTests.java
class Chapter39ApplicationTests (line 17) | @Slf4j
method setUp (line 28) | @Before
method test (line 35) | @Test
FILE: 2.x/chapter4-1/src/main/java/com/didispace/chapter41/Chapter41Application.java
class Chapter41Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter4-1/src/main/java/com/didispace/chapter41/HelloController.java
class HelloController (line 7) | @Controller
method index (line 10) | @GetMapping("/")
FILE: 2.x/chapter4-2/src/main/java/com/didispace/chapter42/Chapter42Application.java
class Chapter42Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter4-2/src/main/java/com/didispace/chapter42/HelloController.java
class HelloController (line 7) | @Controller
method index (line 10) | @GetMapping("/")
FILE: 2.x/chapter4-3/src/main/java/com/didispace/chapter43/Chapter43Application.java
class Chapter43Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter4-3/src/main/java/com/didispace/chapter43/UploadController.java
class UploadController (line 16) | @Controller
method uploadPage (line 23) | @GetMapping("/")
method create (line 28) | @PostMapping("/upload")
FILE: 2.x/chapter4-3/src/test/java/FileTest.java
class FileTest (line 18) | @SpringBootTest(classes = Chapter43Application.class)
method setUp (line 25) | @BeforeEach
method uploadFile (line 30) | @Test
FILE: 2.x/chapter4-4/src/main/java/com/didispace/chapter44/Chapter44Application.java
class Chapter44Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter4-4/src/main/java/com/didispace/chapter44/UploadController.java
class UploadController (line 16) | @Controller
method uploadPage (line 23) | @GetMapping("/")
method create (line 28) | @PostMapping("/upload")
FILE: 2.x/chapter4-4/src/test/java/FileTest.java
class FileTest (line 3) | public class FileTest {
method uploadFile (line 5) | @Test
FILE: 2.x/chapter4-5/src/main/java/com/didispace/chapter45/Application.java
class Application (line 13) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) {
FILE: 2.x/chapter4-5/src/main/java/com/didispace/chapter45/HelloController.java
class HelloController (line 15) | @Controller
method index (line 18) | @RequestMapping("/")
method hello (line 23) | @RequestMapping("/hello")
method login (line 28) | @RequestMapping(value = "/login", method = RequestMethod.GET)
FILE: 2.x/chapter4-5/src/main/java/com/didispace/chapter45/WebSecurityConfig.java
class WebSecurityConfig (line 10) | @Configuration
method configure (line 14) | @Override
method configureGlobal (line 29) | @Autowired
FILE: 2.x/chapter5-1/src/main/java/com/didispace/chapter51/Chapter51Application.java
class Chapter51Application (line 7) | @EnableCaching
method main (line 11) | public static void main(String[] args) {
FILE: 2.x/chapter5-1/src/main/java/com/didispace/chapter51/User.java
class User (line 10) | @Entity
method User (line 22) | public User(String name, Integer age) {
FILE: 2.x/chapter5-1/src/main/java/com/didispace/chapter51/UserRepository.java
type UserRepository (line 15) | @CacheConfig(cacheNames = "users")
method findByName (line 18) | @Cacheable
method findByNameAndAge (line 21) | User findByNameAndAge(String name, Integer age);
method findUser (line 23) | @Query("from User u where u.name=:name")
FILE: 2.x/chapter5-1/src/test/java/com/didispace/chapter51/Chapter51ApplicationTests.java
class Chapter51ApplicationTests (line 11) | @Slf4j
method test (line 22) | @Test
FILE: 2.x/chapter5-2/src/main/java/com/didispace/chapter52/Chapter52Application.java
class Chapter52Application (line 7) | @EnableCaching
method main (line 11) | public static void main(String[] args) {
FILE: 2.x/chapter5-2/src/main/java/com/didispace/chapter52/User.java
class User (line 10) | @Entity
method User (line 22) | public User(String name, Integer age) {
FILE: 2.x/chapter5-2/src/main/java/com/didispace/chapter52/UserRepository.java
type UserRepository (line 15) | @CacheConfig(cacheNames = "users")
method findByName (line 18) | @Cacheable
FILE: 2.x/chapter5-2/src/test/java/com/didispace/chapter52/Chapter52ApplicationTests.java
class Chapter52ApplicationTests (line 11) | @Slf4j
method test (line 22) | @Test
FILE: 2.x/chapter5-3/src/main/java/com/didispace/chapter53/Chapter53Application.java
class Chapter53Application (line 13) | @EnableCaching
method main (line 17) | public static void main(String[] args) throws Exception {
class HelloController (line 22) | @RestController
method create (line 28) | @GetMapping("/create")
method update (line 33) | @GetMapping("/update")
method find (line 41) | @GetMapping("/find")
FILE: 2.x/chapter5-3/src/main/java/com/didispace/chapter53/User.java
class User (line 11) | @Entity
method User (line 23) | public User(String name, Integer age) {
FILE: 2.x/chapter5-3/src/main/java/com/didispace/chapter53/UserRepository.java
type UserRepository (line 15) | @CacheConfig(cacheNames = "users")
method findByName (line 18) | @Cacheable
FILE: 2.x/chapter5-3/src/test/java/com/didispace/chapter53/Chapter53ApplicationTests.java
class Chapter53ApplicationTests (line 11) | @Slf4j
method test (line 22) | @Test
FILE: 2.x/chapter5-4/src/main/java/com/didispace/chapter54/Chapter54Application.java
class Chapter54Application (line 7) | @EnableCaching
method main (line 11) | public static void main(String[] args) {
FILE: 2.x/chapter5-4/src/main/java/com/didispace/chapter54/User.java
class User (line 11) | @Entity
method User (line 23) | public User(String name, Integer age) {
FILE: 2.x/chapter5-4/src/main/java/com/didispace/chapter54/UserRepository.java
type UserRepository (line 15) | @CacheConfig(cacheNames = "users")
method findByName (line 18) | @Cacheable
method findByNameAndAge (line 21) | User findByNameAndAge(String name, Integer age);
method findUser (line 23) | @Query("from User u where u.name=:name")
FILE: 2.x/chapter5-4/src/test/java/com/didispace/chapter54/Chapter54ApplicationTests.java
class Chapter54ApplicationTests (line 11) | @Slf4j
method test (line 22) | @Test
FILE: 2.x/chapter5-5/src/main/java/com/didispace/chapter55/Chapter55Application.java
class Chapter55Application (line 17) | @SpringBootApplication
method main (line 22) | public static void main(String[] args) {
class RedisController (line 26) | @RestController
method RedisController (line 31) | public RedisController(RedisTemplate<String, String> redisTemplate) {
method publish (line 35) | @GetMapping("/publish")
class MessageSubscriber (line 43) | @Slf4j
method MessageSubscriber (line 47) | public MessageSubscriber(RedisTemplate redisTemplate) {
FILE: 2.x/chapter6-1/src/main/java/com/didispace/chapter61/Chapter61Application.java
class Chapter61Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter6-1/src/main/java/com/didispace/chapter61/User.java
class User (line 12) | @Data
FILE: 2.x/chapter6-1/src/main/java/com/didispace/chapter61/UserRepository.java
type UserRepository (line 10) | public interface UserRepository extends MongoRepository<User, Long> {
method findByUsername (line 12) | User findByUsername(String username);
FILE: 2.x/chapter6-1/src/test/java/com/didispace/chapter61/ApplicationTests.java
class ApplicationTests (line 8) | @SpringBootTest(classes = Chapter61Application.class)
method test (line 14) | @Test
FILE: 2.x/chapter6-2/src/main/java/com/didispace/chapter62/Chapter62Application.java
class Chapter62Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter6-2/src/main/java/com/didispace/chapter62/Person.java
class Person (line 8) | @Entry(base = "ou=people,dc=didispace,dc=com", objectClasses = "inetOrgP...
FILE: 2.x/chapter6-2/src/main/java/com/didispace/chapter62/PersonRepository.java
type PersonRepository (line 7) | public interface PersonRepository extends CrudRepository<Person, Name> {
FILE: 2.x/chapter6-2/src/test/java/com/didispace/chapter62/ApplicationTests.java
class ApplicationTests (line 8) | @Slf4j
method findAll (line 15) | @Test
method save (line 24) | @Test
FILE: 2.x/chapter6-3/src/main/java/com/didispace/chapter63/Chapter63Application.java
class Chapter63Application (line 7) | @EnableScheduling
method main (line 11) | public static void main(String[] args) {
FILE: 2.x/chapter6-3/src/main/java/com/didispace/chapter63/Monitor.java
class Monitor (line 19) | @Service
method writeQPS (line 26) | @Scheduled(fixedRate = 5000)
FILE: 2.x/chapter6-3/src/test/java/com/didispace/chapter63/ApplicationTests.java
class ApplicationTests (line 8) | @Slf4j
method findAll (line 12) | @Test
method save (line 17) | @Test
FILE: 2.x/chapter6-4/src/main/java/com/didispace/chapter64/Chapter64Application.java
class Chapter64Application (line 7) | @SpringBootApplication
method main (line 10) | public static void main(String[] args) {
FILE: 2.x/chapter6-4/src/main/java/com/didispace/chapter64/UserInfo.java
class UserInfo (line 10) | @Entity
method UserInfo (line 22) | public UserInfo(String name, Integer age) {
FILE: 2.x/chapter6-4/src/main/java/com/didispace/chapter64/UserInfoRepository.java
type UserInfoRepository (line 13) | public interface UserInfoRepository extends JpaRepository<UserInfo, Long> {
method findByName (line 15) | UserInfo findByName(String name);
method findByNameAndAge (line 17) | UserInfo findByNameAndAge(String name, Integer age);
method findUser (line 19) | @Query("from UserInfo u where u.name=:name")
FILE: 2.x/chapter6-4/src/test/java/com/didispace/chapter64/ApplicationTests.java
class ApplicationTests (line 10) | @Slf4j
method test (line 17) | @Test
FILE: 2.x/chapter7-1/src/main/java/com/didispace/chapter71/Chapter71Application.java
class Chapter71Application (line 7) | @EnableScheduling
method main (line 11) | public static void main(String[] args) {
FILE: 2.x/chapter7-1/src/main/java/com/didispace/chapter71/ScheduledTasks.java
class ScheduledTasks (line 11) | @Slf4j
method reportCurrentTime (line 19) | @Scheduled(fixedRate = 5000)
FILE: 2.x/chapter7-2/src/main/java/com/didispace/chapter72/Chapter72Application.java
class Chapter72Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter7-2/src/main/java/com/didispace/chapter72/MySimpleJob.java
class MySimpleJob (line 8) | @Slf4j
method execute (line 12) | @Override
FILE: 2.x/chapter7-3/src/main/java/com/didispace/chapter73/Chapter73Application.java
class Chapter73Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter7-3/src/main/java/com/didispace/chapter73/MyShardingJob.java
class MyShardingJob (line 8) | @Slf4j
method execute (line 12) | @Override
FILE: 2.x/chapter7-4/src/main/java/com/didispace/chapter74/Chapter74Application.java
class Chapter74Application (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: 2.x/chapter7-4/src/main/java/com/didispace/chapter74/MySimpleJob.java
class MySimpleJob (line 8) | @Slf4j
method execute (line 12) | @Override
FILE: 2.x/chapter7-5/src/main/java/com/didispace/chapter75/AsyncTasks.java
class AsyncTasks (line 10) | @Slf4j
method doTaskOne (line 16) | @Async
method doTaskTwo (line 26) | @Async
method doTaskThree (line 36) | @Async
FILE: 2.x/chapter7-5/src/main/java/com/didispace/chapter75/Chapter75Application.java
class Chapter75Application (line 7) | @EnableAsync
method main (line 11) | public static void main(String[] args) {
FILE: 2.x/chapter7-5/src/test/java/com/didispace/chapter75/Chapter75ApplicationTests.java
class Chapter75ApplicationTests (line 11) | @Slf4j
method test (line 18) | @Test
FILE: 2.x/chapter7-6/src/main/java/com/didispace/chapter76/AsyncTasks.java
class AsyncTasks (line 11) | @Slf4j
method doTaskOne (line 17) | @Async
method doTaskTwo (line 27) | @Async
method doTaskThree (line 37) | @Async
FILE: 2.x/chapter7-6/src/main/java/com/didispace/chapter76/Chapter76Application.java
class Chapter76Application (line 7) | @EnableAsync
method main (line 11) | public static void main(String[] args) {
FILE: 2.x/chapter7-6/src/test/java/com/didispace/chapter76/Chapter76ApplicationTests.java
class Chapter76ApplicationTests (line 10) | @Slf4j
method test1 (line 17) | @Test
FILE: 2.x/chapter7-7/src/main/java/com/didispace/chapter77/AsyncTasks.java
class AsyncTasks (line 10) | @Slf4j
method doTaskOne (line 16) | @Async("taskExecutor1")
method doTaskTwo (line 26) | @Async("taskExecutor2")
FILE: 2.x/chapter7-7/src/main/java/com/didispace/chapter77/Chapter77Application.java
class Chapter77Application (line 17) | @EnableAsync
method main (line 21) | public static void main(String[] args) {
class TaskPoolConfig (line 25) | @EnableAsync
method taskExecutor1 (line 29) | @Bean
method taskExecutor2 (line 41) | @Bean
FILE: 2.x/chapter7-7/src/test/java/com/didispace/chapter77/Chapter77ApplicationTests.java
class Chapter77ApplicationTests (line 11) | @Slf4j
method test (line 18) | @Test
FILE: 2.x/chapter7-8/src/main/java/com/didispace/chapter78/AsyncTasks.java
class AsyncTasks (line 10) | @Slf4j
method doTaskOne (line 16) | @Async("taskExecutor1")
FILE: 2.x/chapter7-8/src/main/java/com/didispace/chapter78/Chapter78Application.java
class Chapter78Application (line 12) | @EnableAsync
method main (line 16) | public static void main(String[] args) {
class TaskPoolConfig (line 20) | @EnableAsync
method taskExecutor1 (line 24) | @Bean
FILE: 2.x/chapter7-8/src/test/java/com/didispace/chapter78/Chapter78ApplicationTests.java
class Chapter78ApplicationTests (line 11) | @Slf4j
method test (line 18) | @Test
method test2 (line 38) | @Test
FILE: 2.x/chapter8-1/src/main/java/com/didispace/chapter81/Chapter81Application.java
class Chapter81Application (line 12) | @Slf4j
method main (line 16) | public static void main(String[] args) {
FILE: 2.x/chapter8-2/src/main/java/com/didispace/chapter82/Chapter82Application.java
class Chapter82Application (line 12) | @Slf4j
method main (line 16) | public static void main(String[] args) {
FILE: 2.x/chapter8-3/src/main/java/com/didispace/chapter83/Chapter83Application.java
class Chapter83Application (line 12) | @Slf4j
method main (line 16) | public static void main(String[] args) {
Condensed preview — 714 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (867K chars).
[
{
"path": ".gitignore",
"chars": 108,
"preview": ".class\n.classpath\n.project\nbuild\nbin\n.bak\n.settings\nThumbs.db\n.DS_Store\n._.DS_Store\nlogs\ntarget\n*.iml\n.idea\n"
},
{
"path": ".gitmodules",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter1/pom.xml",
"chars": 1519,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/"
},
{
"path": "1.x/Chapter1/src/main/java/com/didispace/Chapter1Application.java",
"chars": 310,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter1/src/main/java/com/didispace/web/HelloController.java",
"chars": 299,
"preview": "package com.didispace.web;\n\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.we"
},
{
"path": "1.x/Chapter1/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter1/src/test/java/com/didispace/Chapter1ApplicationTests.java",
"chars": 1424,
"preview": "package com.didispace;\n\nimport com.didispace.web.HelloController;\nimport org.junit.Before;\nimport org.junit.Test;\nimport"
},
{
"path": "1.x/Chapter2-1-1/pom.xml",
"chars": 1446,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter2-1-1/src/main/java/com/didispace/Application.java",
"chars": 380,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter2-1-1/src/main/java/com/didispace/service/BlogProperties.java",
"chars": 1948,
"preview": "package com.didispace.service;\n\nimport org.springframework.beans.factory.annotation.Value;\nimport org.springframework.st"
},
{
"path": "1.x/Chapter2-1-1/src/main/java/com/didispace/web/HelloController.java",
"chars": 383,
"preview": "package com.didispace.web;\n\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.we"
},
{
"path": "1.x/Chapter2-1-1/src/main/resources/application-dev.properties",
"chars": 23,
"preview": "# 服务端口\nserver.port=1111"
},
{
"path": "1.x/Chapter2-1-1/src/main/resources/application-prod.properties",
"chars": 23,
"preview": "# 服务端口\nserver.port=3333"
},
{
"path": "1.x/Chapter2-1-1/src/main/resources/application-test.properties",
"chars": 23,
"preview": "# 服务端口\nserver.port=2222"
},
{
"path": "1.x/Chapter2-1-1/src/main/resources/application.properties",
"chars": 458,
"preview": "com.didispace.blog.name=程序猿DD\ncom.didispace.blog.title=Spring Boot教程\ncom.didispace.blog.desc=${com.didispace.blog.name}正"
},
{
"path": "1.x/Chapter2-1-1/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1411,
"preview": "package com.didispace;\n\nimport com.didispace.service.BlogProperties;\nimport org.apache.commons.logging.Log;\nimport org.a"
},
{
"path": "1.x/Chapter2-1-2/pom.xml",
"chars": 1760,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter2-1-2/src/main/java/com/didispace/Application.java",
"chars": 746,
"preview": "package com.didispace;\n\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.boot.CommandLineRunner;\nimport org."
},
{
"path": "1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationEnvironmentPreparedEventListener.java",
"chars": 505,
"preview": "package com.didispace;\n\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.boot.context.event.ApplicationEnvir"
},
{
"path": "1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationFailedEventListener.java",
"chars": 440,
"preview": "package com.didispace;\n\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.boot.context.event.ApplicationFaile"
},
{
"path": "1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationPreparedEventListener.java",
"chars": 450,
"preview": "package com.didispace;\n\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.boot.context.event.ApplicationPrepa"
},
{
"path": "1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationReadyEventListener.java",
"chars": 435,
"preview": "package com.didispace;\n\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.boot.context.event.ApplicationReady"
},
{
"path": "1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationStartedEventListener.java",
"chars": 496,
"preview": "package com.didispace;\n\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.boot.SpringApplication;\nimport org."
},
{
"path": "1.x/Chapter2-1-2/src/main/java/com/didispace/ApplicationStartingEventListener.java",
"chars": 450,
"preview": "package com.didispace;\n\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.boot.context.event.ApplicationStart"
},
{
"path": "1.x/Chapter2-1-2/src/main/resources/META-INF/spring.factories",
"chars": 354,
"preview": "org.springframework.context.ApplicationListener=com.didispace.ApplicationEnvironmentPreparedEventListener,\\\n com.didisp"
},
{
"path": "1.x/Chapter2-1-2/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter2-2-1/pom.xml",
"chars": 1327,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter2-2-1/src/main/java/com/didispace/Application.java",
"chars": 1375,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter2-2-1/src/main/java/com/didispace/FooProperties.java",
"chars": 272,
"preview": "package com.didispace;\n\nimport lombok.Data;\nimport org.springframework.boot.context.properties.ConfigurationProperties;\n"
},
{
"path": "1.x/Chapter2-2-1/src/main/java/com/didispace/PostInfo.java",
"chars": 234,
"preview": "package com.didispace;\n\nimport lombok.Data;\nimport org.springframework.boot.context.properties.ConfigurationProperties;\n"
},
{
"path": "1.x/Chapter2-2-1/src/main/resources/application.properties",
"chars": 324,
"preview": "com.didispace.foo=bar\ncom.didispace.database-platform=sql\n\ncom.didispace.post[0]=Why Spring Boot\ncom.didispace.post[1]=W"
},
{
"path": "1.x/Chapter3-1-1/pom.xml",
"chars": 1519,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/"
},
{
"path": "1.x/Chapter3-1-1/src/main/java/com/didispace/Application.java",
"chars": 380,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-1-1/src/main/java/com/didispace/domain/User.java",
"chars": 581,
"preview": "package com.didispace.domain;\n\n\n\n/**\n *\n * @author 程序猿DD\n * @version 1.0.0\n * @blog http://blog.didispace.com\n *\n */\npub"
},
{
"path": "1.x/Chapter3-1-1/src/main/java/com/didispace/web/HelloController.java",
"chars": 383,
"preview": "package com.didispace.web;\n\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.we"
},
{
"path": "1.x/Chapter3-1-1/src/main/java/com/didispace/web/UserController.java",
"chars": 1790,
"preview": "package com.didispace.web;\n\nimport com.didispace.domain.User;\n\nimport java.util.*;\n\nimport org.springframework.web.bind."
},
{
"path": "1.x/Chapter3-1-1/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter3-1-1/src/test/java/com/didispace/ApplicationTests.java",
"chars": 3110,
"preview": "package com.didispace;\n\nimport com.didispace.domain.User;\nimport com.didispace.web.HelloController;\nimport com.didispace"
},
{
"path": "1.x/Chapter3-1-2/pom.xml",
"chars": 1733,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/"
},
{
"path": "1.x/Chapter3-1-2/src/main/java/com/didispace/Application.java",
"chars": 380,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-1-2/src/main/java/com/didispace/web/HelloController.java",
"chars": 679,
"preview": "package com.didispace.web;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.ui.ModelMap;"
},
{
"path": "1.x/Chapter3-1-2/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter3-1-2/src/main/resources/templates/index.html",
"chars": 158,
"preview": "<!DOCTYPE html>\n<html>\n<head lang=\"en\">\n <meta charset=\"UTF-8\" />\n <title></title>\n</head>\n<body>\n<h1 th:text=\"${h"
},
{
"path": "1.x/Chapter3-1-2/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1505,
"preview": "package com.didispace;\n\nimport com.didispace.web.HelloController;\nimport org.junit.Before;\nimport org.junit.Test;\nimport"
},
{
"path": "1.x/Chapter3-1-3/pom.xml",
"chars": 1656,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter3-1-3/src/main/java/com/didispace/Application.java",
"chars": 380,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-1-3/src/main/java/com/didispace/web/HelloController.java",
"chars": 675,
"preview": "package com.didispace.web;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.ui.ModelMap;"
},
{
"path": "1.x/Chapter3-1-3/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter3-1-3/src/main/resources/templates/index.ftl",
"chars": 151,
"preview": "<!DOCTYPE html>\n<html>\n<head lang=\"en\">\n <meta charset=\"UTF-8\" />\n <title></title>\n</head>\n<body>\nFreeMarker模板引擎\n<"
},
{
"path": "1.x/Chapter3-1-3/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1505,
"preview": "package com.didispace;\n\nimport com.didispace.web.HelloController;\nimport org.junit.Before;\nimport org.junit.Test;\nimport"
},
{
"path": "1.x/Chapter3-1-4/pom.xml",
"chars": 1654,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter3-1-4/src/main/java/com/didispace/Application.java",
"chars": 380,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-1-4/src/main/java/com/didispace/web/HelloController.java",
"chars": 675,
"preview": "package com.didispace.web;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.ui.ModelMap;"
},
{
"path": "1.x/Chapter3-1-4/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter3-1-4/src/main/resources/templates/index.vm",
"chars": 147,
"preview": "<!DOCTYPE html>\n<html>\n<head lang=\"en\">\n <meta charset=\"UTF-8\" />\n <title></title>\n</head>\n<body>\nVelocity模板\n<h1>$"
},
{
"path": "1.x/Chapter3-1-4/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1505,
"preview": "package com.didispace;\n\nimport com.didispace.web.HelloController;\nimport org.junit.Before;\nimport org.junit.Test;\nimport"
},
{
"path": "1.x/Chapter3-1-5/pom.xml",
"chars": 1771,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter3-1-5/src/main/java/com/didispace/Application.java",
"chars": 380,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-1-5/src/main/java/com/didispace/Swagger2.java",
"chars": 1399,
"preview": "package com.didispace;\n\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.context.annotatio"
},
{
"path": "1.x/Chapter3-1-5/src/main/java/com/didispace/domain/User.java",
"chars": 581,
"preview": "package com.didispace.domain;\n\n\n\n/**\n *\n * @author 程序猿DD\n * @version 1.0.0\n * @blog http://blog.didispace.com\n *\n */\npub"
},
{
"path": "1.x/Chapter3-1-5/src/main/java/com/didispace/web/HelloController.java",
"chars": 550,
"preview": "package com.didispace.web;\n\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.we"
},
{
"path": "1.x/Chapter3-1-5/src/main/java/com/didispace/web/UserController.java",
"chars": 2301,
"preview": "package com.didispace.web;\n\nimport com.didispace.domain.User;\n\nimport java.util.*;\n\nimport io.swagger.annotations.*;\nimp"
},
{
"path": "1.x/Chapter3-1-5/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter3-1-6/pom.xml",
"chars": 1657,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter3-1-6/src/main/java/com/didispace/Application.java",
"chars": 380,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-1-6/src/main/java/com/didispace/dto/ErrorInfo.java",
"chars": 901,
"preview": "package com.didispace.dto;\n\npublic class ErrorInfo<T> {\n\n public static final Integer OK = 0;\n public static final"
},
{
"path": "1.x/Chapter3-1-6/src/main/java/com/didispace/exception/GlobalExceptionHandler.java",
"chars": 1168,
"preview": "package com.didispace.exception;\n\nimport com.didispace.dto.ErrorInfo;\nimport org.springframework.web.bind.annotation.Con"
},
{
"path": "1.x/Chapter3-1-6/src/main/java/com/didispace/exception/MyException.java",
"chars": 257,
"preview": "package com.didispace.exception;\n\n/**\n * @author 程序猿DD\n * @version 1.0.0\n * @date 16/5/2 上午10:50.\n * @blog http://blog.d"
},
{
"path": "1.x/Chapter3-1-6/src/main/java/com/didispace/web/HelloController.java",
"chars": 818,
"preview": "package com.didispace.web;\n\nimport com.didispace.exception.MyException;\nimport org.springframework.stereotype.Controller"
},
{
"path": "1.x/Chapter3-1-6/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter3-1-6/src/main/resources/templates/error.html",
"chars": 220,
"preview": "<!DOCTYPE html>\n<html>\n<head lang=\"en\">\n <meta charset=\"UTF-8\" />\n <title>统一异常处理</title>\n</head>\n<body>\n<h1>Error "
},
{
"path": "1.x/Chapter3-1-6/src/main/resources/templates/index.html",
"chars": 158,
"preview": "<!DOCTYPE html>\n<html>\n<head lang=\"en\">\n <meta charset=\"UTF-8\" />\n <title></title>\n</head>\n<body>\n<h1 th:text=\"${h"
},
{
"path": "1.x/Chapter3-1-6/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1123,
"preview": "package com.didispace;\n\nimport com.didispace.web.HelloController;\nimport org.junit.Before;\nimport org.junit.Test;\nimport"
},
{
"path": "1.x/Chapter3-1-7/pom.xml",
"chars": 1668,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter3-1-7/src/main/java/com/didispace/Application.java",
"chars": 1563,
"preview": "package com.didispace;\n\nimport com.fasterxml.jackson.databind.ObjectMapper;\nimport com.fasterxml.jackson.databind.Serial"
},
{
"path": "1.x/Chapter3-1-7/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter3-1-8/pom.xml",
"chars": 1634,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter3-1-8/src/main/java/com/didispace/Application.java",
"chars": 384,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-1-8/src/main/java/com/didispace/web/User.java",
"chars": 597,
"preview": "package com.didispace.web;\n\n\nimport com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;\nimport com.faste"
},
{
"path": "1.x/Chapter3-1-8/src/main/java/com/didispace/web/UserController.java",
"chars": 618,
"preview": "package com.didispace.web;\n\nimport org.springframework.http.MediaType;\nimport org.springframework.stereotype.Controller;"
},
{
"path": "1.x/Chapter3-1-8/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter3-2-1/pom.xml",
"chars": 1672,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/"
},
{
"path": "1.x/Chapter3-2-1/src/main/java/com/didispace/Application.java",
"chars": 294,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-2-1/src/main/java/com/didispace/service/UserService.java",
"chars": 490,
"preview": "package com.didispace.service;\n\n/**\n * @author 程序猿DD\n * @version 1.0.0\n * @date 16/3/17 下午7:04.\n * @blog http://blog.did"
},
{
"path": "1.x/Chapter3-2-1/src/main/java/com/didispace/service/UserServiceImpl.java",
"chars": 957,
"preview": "package com.didispace.service;\n\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframewor"
},
{
"path": "1.x/Chapter3-2-1/src/main/resources/application.properties",
"chars": 179,
"preview": "spring.datasource.url=jdbc:mysql://localhost:3306/test\r\nspring.datasource.username=root\r\nspring.datasource.password=root"
},
{
"path": "1.x/Chapter3-2-1/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1094,
"preview": "package com.didispace;\n\nimport com.didispace.service.UserService;\nimport org.junit.Assert;\nimport org.junit.Before;\nimpo"
},
{
"path": "1.x/Chapter3-2-10/pom.xml",
"chars": 1772,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter3-2-10/src/main/java/com/didispace/Application.java",
"chars": 294,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-2-10/src/main/java/com/didispace/Person.java",
"chars": 480,
"preview": "package com.didispace;\n\nimport lombok.Data;\nimport org.springframework.ldap.odm.annotations.*;\n\nimport javax.naming.Name"
},
{
"path": "1.x/Chapter3-2-10/src/main/java/com/didispace/PersonRepository.java",
"chars": 187,
"preview": "package com.didispace;\n\nimport org.springframework.data.repository.CrudRepository;\n\nimport javax.naming.Name;\n\npublic in"
},
{
"path": "1.x/Chapter3-2-10/src/main/resources/application.properties",
"chars": 138,
"preview": "#spring.ldap.urls=ldap://localhost:1235\n#spring.ldap.base=dc=didispace,dc=com\n#spring.ldap.username=didispace\n#spring.ld"
},
{
"path": "1.x/Chapter3-2-10/src/test/java/com/didispace/ApplicationTests.java",
"chars": 848,
"preview": "package com.didispace;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.springframework.beans.factory"
},
{
"path": "1.x/Chapter3-2-10/src/test/resources/application.properties",
"chars": 93,
"preview": "spring.ldap.embedded.ldif=ldap-server.ldif\nspring.ldap.embedded.base-dn=dc=didispace,dc=com\n\n"
},
{
"path": "1.x/Chapter3-2-10/src/test/resources/ldap-server.ldif",
"chars": 381,
"preview": "dn: dc=didispace,dc=com\nobjectClass: top\nobjectClass: domain\n\ndn: ou=people,dc=didispace,dc=com\nobjectclass: top\nobjectc"
},
{
"path": "1.x/Chapter3-2-11/pom.xml",
"chars": 2136,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter3-2-11/src/main/java/com/didispace/Application.java",
"chars": 370,
"preview": "package com.didispace;\n\nimport com.spring4all.mongodb.EnableMongoPlus;\nimport org.springframework.boot.SpringApplication"
},
{
"path": "1.x/Chapter3-2-11/src/main/resources/application.properties",
"chars": 165,
"preview": "spring.data.mongodb.uri=mongodb://localhost:27017/test\n\nspring.data.mongodb.option.min-connection-per-host=20\nspring.dat"
},
{
"path": "1.x/Chapter3-2-11/src/test/java/com/didispace/ApplicationTests.java",
"chars": 765,
"preview": "package com.didispace;\n\nimport com.mongodb.MongoClient;\nimport lombok.extern.slf4j.Slf4j;\nimport org.junit.Test;\nimport "
},
{
"path": "1.x/Chapter3-2-2/pom.xml",
"chars": 1666,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/"
},
{
"path": "1.x/Chapter3-2-2/src/main/java/com/didispace/Application.java",
"chars": 294,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-2-2/src/main/java/com/didispace/domain/User.java",
"chars": 956,
"preview": "package com.didispace.domain;\n\nimport javax.persistence.Column;\nimport javax.persistence.Entity;\nimport javax.persistenc"
},
{
"path": "1.x/Chapter3-2-2/src/main/java/com/didispace/domain/UserRepository.java",
"chars": 562,
"preview": "package com.didispace.domain;\n\nimport org.springframework.data.jpa.repository.JpaRepository;\nimport org.springframework."
},
{
"path": "1.x/Chapter3-2-2/src/main/resources/application.properties",
"chars": 234,
"preview": "spring.datasource.url=jdbc:mysql://localhost:3306/test\nspring.datasource.username=root\nspring.datasource.password=root\ns"
},
{
"path": "1.x/Chapter3-2-2/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1695,
"preview": "package com.didispace;\n\nimport com.didispace.domain.User;\nimport com.didispace.domain.UserRepository;\nimport org.junit.A"
},
{
"path": "1.x/Chapter3-2-3/pom.xml",
"chars": 1662,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/"
},
{
"path": "1.x/Chapter3-2-3/src/main/java/com/didispace/Application.java",
"chars": 628,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-2-3/src/main/java/com/didispace/DataSourceConfig.java",
"chars": 1557,
"preview": "package com.didispace;\n\nimport org.springframework.beans.factory.annotation.Qualifier;\nimport org.springframework.boot.a"
},
{
"path": "1.x/Chapter3-2-3/src/main/resources/application.properties",
"chars": 429,
"preview": "spring.datasource.primary.url=jdbc:mysql://localhost:3306/test1\nspring.datasource.primary.username=root\nspring.datasourc"
},
{
"path": "1.x/Chapter3-2-3/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1526,
"preview": "package com.didispace;\n\nimport org.junit.Assert;\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner"
},
{
"path": "1.x/Chapter3-2-4/pom.xml",
"chars": 1668,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/"
},
{
"path": "1.x/Chapter3-2-4/src/main/java/com/didispace/Application.java",
"chars": 628,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-2-4/src/main/java/com/didispace/DataSourceConfig.java",
"chars": 1088,
"preview": "package com.didispace;\n\nimport org.springframework.beans.factory.annotation.Qualifier;\nimport org.springframework.boot.a"
},
{
"path": "1.x/Chapter3-2-4/src/main/java/com/didispace/PrimaryConfig.java",
"chars": 2453,
"preview": "package com.didispace;\n\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.beans."
},
{
"path": "1.x/Chapter3-2-4/src/main/java/com/didispace/SecondaryConfig.java",
"chars": 2382,
"preview": "package com.didispace;\n\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.beans."
},
{
"path": "1.x/Chapter3-2-4/src/main/java/com/didispace/domain/p/User.java",
"chars": 958,
"preview": "package com.didispace.domain.p;\n\nimport javax.persistence.Column;\nimport javax.persistence.Entity;\nimport javax.persiste"
},
{
"path": "1.x/Chapter3-2-4/src/main/java/com/didispace/domain/p/UserRepository.java",
"chars": 382,
"preview": "package com.didispace.domain.p;\n\nimport org.springframework.data.jpa.repository.JpaRepository;\nimport org.springframewor"
},
{
"path": "1.x/Chapter3-2-4/src/main/java/com/didispace/domain/s/Message.java",
"chars": 1003,
"preview": "package com.didispace.domain.s;\n\nimport javax.persistence.Column;\nimport javax.persistence.Entity;\nimport javax.persiste"
},
{
"path": "1.x/Chapter3-2-4/src/main/java/com/didispace/domain/s/MessageRepository.java",
"chars": 278,
"preview": "package com.didispace.domain.s;\n\nimport org.springframework.data.jpa.repository.JpaRepository;\n\n\n/**\n * @author 程序猿DD\n *"
},
{
"path": "1.x/Chapter3-2-4/src/main/resources/application.properties",
"chars": 494,
"preview": "spring.datasource.primary.url=jdbc:mysql://localhost:3306/test1\nspring.datasource.primary.username=root\nspring.datasourc"
},
{
"path": "1.x/Chapter3-2-4/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1353,
"preview": "package com.didispace;\n\nimport com.didispace.domain.p.User;\nimport com.didispace.domain.p.UserRepository;\nimport com.did"
},
{
"path": "1.x/Chapter3-2-5/pom.xml",
"chars": 1519,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/"
},
{
"path": "1.x/Chapter3-2-5/src/main/java/com/didispace/Application.java",
"chars": 294,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-2-5/src/main/java/com/didispace/RedisConfig.java",
"chars": 1105,
"preview": "package com.didispace;\n\nimport com.didispace.domain.User;\nimport org.springframework.context.annotation.Bean;\nimport org"
},
{
"path": "1.x/Chapter3-2-5/src/main/java/com/didispace/RedisObjectSerializer.java",
"chars": 1221,
"preview": "package com.didispace;\n\nimport org.springframework.core.convert.converter.Converter;\nimport org.springframework.core.ser"
},
{
"path": "1.x/Chapter3-2-5/src/main/java/com/didispace/domain/User.java",
"chars": 714,
"preview": "package com.didispace.domain;\n\nimport java.io.Serializable;\n\n/**\n * @author 程序猿DD\n * @version 1.0.0\n * @date 16/4/15 下午1"
},
{
"path": "1.x/Chapter3-2-5/src/main/resources/application.properties",
"chars": 426,
"preview": "# REDIS (RedisProperties)\n# Redis数据库索引(默认为0)\nspring.redis.database=0\n# Redis服务器地址\nspring.redis.host=localhost\n# Redis服务器"
},
{
"path": "1.x/Chapter3-2-5/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1532,
"preview": "package com.didispace;\n\nimport com.didispace.domain.User;\nimport org.junit.Assert;\nimport org.junit.Test;\nimport org.jun"
},
{
"path": "1.x/Chapter3-2-6/pom.xml",
"chars": 1459,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter3-2-6/src/main/java/com/didispace/Application.java",
"chars": 294,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-2-6/src/main/java/com/didispace/domain/User.java",
"chars": 828,
"preview": "package com.didispace.domain;\n\nimport org.springframework.data.annotation.Id;\n\n/**\n * @author 程序猿DD\n * @version 1.0.0\n *"
},
{
"path": "1.x/Chapter3-2-6/src/main/java/com/didispace/domain/UserRepository.java",
"chars": 320,
"preview": "package com.didispace.domain;\n\nimport org.springframework.data.mongodb.repository.MongoRepository;\n\n/**\n * @author 程序猿DD"
},
{
"path": "1.x/Chapter3-2-6/src/main/resources/application.properties",
"chars": 67,
"preview": "spring.data.mongodb.uri=mongodb://name:pass@localhost:27017/test\n\n\n"
},
{
"path": "1.x/Chapter3-2-6/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1249,
"preview": "package com.didispace;\n\nimport com.didispace.domain.User;\nimport com.didispace.domain.UserRepository;\nimport org.junit.A"
},
{
"path": "1.x/Chapter3-2-7/pom.xml",
"chars": 1634,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter3-2-7/src/main/java/com/didispace/Application.java",
"chars": 294,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-2-7/src/main/java/com/didispace/domain/User.java",
"chars": 496,
"preview": "package com.didispace.domain;\n\npublic class User {\n\n private Long id;\n private String name;\n private Integer ag"
},
{
"path": "1.x/Chapter3-2-7/src/main/java/com/didispace/domain/UserMapper.java",
"chars": 356,
"preview": "package com.didispace.domain;\n\nimport org.apache.ibatis.annotations.*;\n\n@Mapper\npublic interface UserMapper {\n\n @Sele"
},
{
"path": "1.x/Chapter3-2-7/src/main/resources/application.properties",
"chars": 178,
"preview": "spring.datasource.url=jdbc:mysql://localhost:3306/test\nspring.datasource.username=root\nspring.datasource.password=123456"
},
{
"path": "1.x/Chapter3-2-7/src/test/java/com/didispace/ApplicationTests.java",
"chars": 888,
"preview": "package com.didispace;\n\nimport com.didispace.domain.User;\nimport com.didispace.domain.UserMapper;\nimport org.junit.Asser"
},
{
"path": "1.x/Chapter3-2-8/pom.xml",
"chars": 1634,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter3-2-8/src/main/java/com/didispace/Application.java",
"chars": 294,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-2-8/src/main/java/com/didispace/domain/User.java",
"chars": 756,
"preview": "package com.didispace.domain;\n\npublic class User {\n\n private Long id;\n private String name;\n private Integer ag"
},
{
"path": "1.x/Chapter3-2-8/src/main/java/com/didispace/domain/UserMapper.java",
"chars": 1018,
"preview": "package com.didispace.domain;\n\nimport org.apache.ibatis.annotations.*;\n\nimport java.util.List;\nimport java.util.Map;\n\n@M"
},
{
"path": "1.x/Chapter3-2-8/src/main/resources/application.properties",
"chars": 178,
"preview": "spring.datasource.url=jdbc:mysql://localhost:3306/test\nspring.datasource.username=root\nspring.datasource.password=123456"
},
{
"path": "1.x/Chapter3-2-8/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1806,
"preview": "package com.didispace;\n\nimport com.didispace.domain.User;\nimport com.didispace.domain.UserMapper;\nimport org.junit.Asser"
},
{
"path": "1.x/Chapter3-2-9/pom.xml",
"chars": 1620,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter3-2-9/src/main/java/com/didispace/Application.java",
"chars": 294,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-2-9/src/main/java/com/didispace/service/UserService.java",
"chars": 490,
"preview": "package com.didispace.service;\n\n/**\n * @author 程序猿DD\n * @version 1.0.0\n * @date 16/3/17 下午7:04.\n * @blog http://blog.did"
},
{
"path": "1.x/Chapter3-2-9/src/main/java/com/didispace/service/UserServiceImpl.java",
"chars": 957,
"preview": "package com.didispace.service;\n\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframewor"
},
{
"path": "1.x/Chapter3-2-9/src/main/resources/application.properties",
"chars": 204,
"preview": "spring.datasource.url=jdbc:mysql://localhost:3306/test\nspring.datasource.username=root\nspring.datasource.password=\nsprin"
},
{
"path": "1.x/Chapter3-2-9/src/main/resources/db/V1__Base_version.sql",
"chars": 258,
"preview": "DROP TABLE IF EXISTS `user` ;\n\n\nCREATE TABLE `user` (\n `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',\n `name` v"
},
{
"path": "1.x/Chapter3-2-9/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1051,
"preview": "package com.didispace;\n\nimport com.didispace.service.UserService;\nimport org.junit.Assert;\nimport org.junit.Before;\nimpo"
},
{
"path": "1.x/Chapter3-3-1/pom.xml",
"chars": 1607,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter3-3-1/src/main/java/com/didispace/Application.java",
"chars": 294,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter3-3-1/src/main/java/com/didispace/domain/User.java",
"chars": 968,
"preview": "package com.didispace.domain;\n\nimport javax.persistence.Column;\nimport javax.persistence.Entity;\nimport javax.persistenc"
},
{
"path": "1.x/Chapter3-3-1/src/main/java/com/didispace/domain/UserRepository.java",
"chars": 562,
"preview": "package com.didispace.domain;\n\nimport org.springframework.data.jpa.repository.JpaRepository;\nimport org.springframework."
},
{
"path": "1.x/Chapter3-3-1/src/main/java/com/didispace/service/UserService.java",
"chars": 474,
"preview": "package com.didispace.service;\n\nimport com.didispace.domain.User;\nimport org.springframework.transaction.annotation.Prop"
},
{
"path": "1.x/Chapter3-3-1/src/main/resources/application.properties",
"chars": 231,
"preview": "spring.datasource.url=jdbc:mysql://localhost:3306/test\nspring.datasource.username=root\nspring.datasource.password=123456"
},
{
"path": "1.x/Chapter3-3-1/src/test/java/com/didispace/ApplicationTests.java",
"chars": 1782,
"preview": "package com.didispace;\n\nimport com.didispace.domain.User;\nimport com.didispace.domain.UserRepository;\nimport org.junit.A"
},
{
"path": "1.x/Chapter4-1-1/pom.xml",
"chars": 1334,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter4-1-1/src/main/java/com/didispace/Application.java",
"chars": 379,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter4-1-1/src/main/java/com/didispace/task/ScheduledTasks.java",
"chars": 479,
"preview": "package com.didispace.task;\n\nimport org.springframework.scheduling.annotation.Scheduled;\nimport org.springframework.ster"
},
{
"path": "1.x/Chapter4-1-1/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter4-1-1/src/test/java/com/didispace/ApplicationTests.java",
"chars": 414,
"preview": "package com.didispace;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.springframework.boot.test.Spr"
},
{
"path": "1.x/Chapter4-1-2/pom.xml",
"chars": 1334,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter4-1-2/src/main/java/com/didispace/Application.java",
"chars": 436,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter4-1-2/src/main/java/com/didispace/async/Task.java",
"chars": 1531,
"preview": "package com.didispace.async;\n\nimport org.springframework.scheduling.annotation.Async;\nimport org.springframework.schedul"
},
{
"path": "1.x/Chapter4-1-2/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter4-1-2/src/test/java/com/didispace/ApplicationTests.java",
"chars": 999,
"preview": "package com.didispace;\n\nimport com.didispace.async.Task;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport "
},
{
"path": "1.x/Chapter4-1-3/pom.xml",
"chars": 1757,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter4-1-3/src/main/java/com/didispace/Application.java",
"chars": 1224,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter4-1-3/src/main/java/com/didispace/async/Task.java",
"chars": 1304,
"preview": "package com.didispace.async;\n\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.scheduling.annotation.Async;\n"
},
{
"path": "1.x/Chapter4-1-3/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter4-1-3/src/test/java/com/didispace/ApplicationTests.java",
"chars": 621,
"preview": "package com.didispace;\n\nimport com.didispace.async.Task;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport "
},
{
"path": "1.x/Chapter4-1-4/pom.xml",
"chars": 1924,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter4-1-4/src/main/java/com/didispace/Application.java",
"chars": 1069,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter4-1-4/src/main/java/com/didispace/async/Task.java",
"chars": 1443,
"preview": "package com.didispace.async;\n\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.beans.factory.annotation.Auto"
},
{
"path": "1.x/Chapter4-1-4/src/main/resources/application.properties",
"chars": 64,
"preview": "spring.redis.pool.max-wait=5000\nspring.redis.pool.max-active=10\n"
},
{
"path": "1.x/Chapter4-1-4/src/test/java/com/didispace/ApplicationTests.java",
"chars": 750,
"preview": "package com.didispace;\n\nimport com.didispace.async.Task;\nimport lombok.SneakyThrows;\nimport org.junit.Test;\nimport org.j"
},
{
"path": "1.x/Chapter4-1-5/pom.xml",
"chars": 1757,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter4-1-5/src/main/java/com/didispace/Application.java",
"chars": 1224,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
},
{
"path": "1.x/Chapter4-1-5/src/main/java/com/didispace/async/Task.java",
"chars": 760,
"preview": "package com.didispace.async;\n\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.scheduling.annotation.Async;\n"
},
{
"path": "1.x/Chapter4-1-5/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter4-1-5/src/test/java/com/didispace/ApplicationTests.java",
"chars": 754,
"preview": "package com.didispace;\n\nimport com.didispace.async.Task;\nimport lombok.extern.slf4j.Slf4j;\nimport org.junit.Test;\nimport"
},
{
"path": "1.x/Chapter4-2-2/pom.xml",
"chars": 1641,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter4-2-2/src/main/java/com/didispace/Application.java",
"chars": 455,
"preview": "package com.didispace;\n\nimport org.apache.log4j.Logger;\nimport org.springframework.boot.SpringApplication;\nimport org.sp"
},
{
"path": "1.x/Chapter4-2-2/src/main/resources/application.properties",
"chars": 0,
"preview": ""
},
{
"path": "1.x/Chapter4-2-2/src/main/resources/log4j.properties",
"chars": 1388,
"preview": "# LOG4J配置\nlog4j.rootCategory=INFO, stdout, file, errorfile\nlog4j.category.com.didispace=DEBUG, didifile\nlog4j.logger.err"
},
{
"path": "1.x/Chapter4-2-2/src/test/java/com/didispace/ApplicationTests.java",
"chars": 576,
"preview": "package com.didispace;\n\nimport org.apache.log4j.Logger;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport o"
},
{
"path": "1.x/Chapter4-2-3/pom.xml",
"chars": 1641,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter4-2-3/src/main/java/com/didispace/Application.java",
"chars": 455,
"preview": "package com.didispace;\n\nimport org.apache.log4j.Logger;\nimport org.springframework.boot.SpringApplication;\nimport org.sp"
},
{
"path": "1.x/Chapter4-2-3/src/main/resources/application-dev.properties",
"chars": 32,
"preview": "logging.level.com.didispace=INFO"
},
{
"path": "1.x/Chapter4-2-3/src/main/resources/application-prod.properties",
"chars": 32,
"preview": "logging.level.com.didispace=INFO"
},
{
"path": "1.x/Chapter4-2-3/src/main/resources/application-test.properties",
"chars": 33,
"preview": "logging.level.com.didispace=DEBUG"
},
{
"path": "1.x/Chapter4-2-3/src/main/resources/application.properties",
"chars": 26,
"preview": "spring.profiles.active=dev"
},
{
"path": "1.x/Chapter4-2-3/src/main/resources/log4j.properties",
"chars": 1413,
"preview": "# LOG4J配置\nlog4j.rootCategory=INFO, stdout, file, errorfile\nlog4j.category.com.didispace=${logging.level.com.didispace}, "
},
{
"path": "1.x/Chapter4-2-3/src/test/java/com/didispace/ApplicationTests.java",
"chars": 576,
"preview": "package com.didispace;\n\nimport org.apache.log4j.Logger;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport o"
},
{
"path": "1.x/Chapter4-2-4/pom.xml",
"chars": 1903,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "1.x/Chapter4-2-4/src/main/java/com/didispace/Application.java",
"chars": 294,
"preview": "package com.didispace;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure"
}
]
// ... and 514 more files (download for full content)
About this extraction
This page contains the full source code of the dyc87112/SpringBoot-Learning GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 714 files (743.5 KB), approximately 249.8k tokens, and a symbol index with 1104 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.