├── README.md
├── ch10
├── ch10.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch10
│ │ │ ├── Ch10Application.java
│ │ │ └── DemoController.java
│ └── resources
│ │ ├── application.properties
│ │ └── templates
│ │ └── index.html
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch10
│ └── Ch10ApplicationTests.java
├── ch10_4
├── ch10_4.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch10_4
│ │ │ ├── Ch104Application.java
│ │ │ ├── dao
│ │ │ └── PersonRepository.java
│ │ │ ├── domain
│ │ │ └── Person.java
│ │ │ └── web
│ │ │ └── PersonController.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch10_4
│ └── Ch104ApplicationTests.java
├── ch10docker
├── ch10docker.iml
├── pom.xml
└── src
│ ├── main
│ ├── docker
│ │ └── Dockerfile
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── Ch10dockerApplication.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── Ch10dockerApplicationTests.java
├── ch10war
├── ch10war.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch10war
│ │ │ ├── Ch10warApplication.java
│ │ │ ├── DemoController.java
│ │ │ └── ServletInitializer.java
│ └── resources
│ │ ├── application.properties
│ │ └── templates
│ │ └── index.html
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch10war
│ └── Ch10warApplicationTests.java
├── ch11_1
├── ch11_1.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch11_1
│ │ │ ├── DemoApplication.java
│ │ │ ├── StatusEndPoint.java
│ │ │ ├── StatusHealth.java
│ │ │ └── StatusService.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch12_1
│ └── DemoApplicationTests.java
├── ch11_3
├── ch11_3.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch11_3
│ │ │ └── Ch123Application.java
│ └── resources
│ │ ├── application.properties
│ │ └── commands
│ │ └── hello.groovy
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch12_3
│ └── Ch123ApplicationTests.java
├── ch12
├── ch12.iml
├── config
│ ├── config.iml
│ ├── pom.xml
│ ├── src
│ │ └── main
│ │ │ ├── docker
│ │ │ ├── Dockerfile
│ │ │ └── runboot.sh
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── wisely
│ │ │ │ └── config
│ │ │ │ └── ConfigApplication.java
│ │ │ └── resources
│ │ │ ├── application.yml
│ │ │ ├── bootstrap.yml
│ │ │ └── config
│ │ │ ├── person-docker.yml
│ │ │ ├── person.yml
│ │ │ ├── some-docker.yml
│ │ │ └── some.yml
│ └── target
│ │ ├── classes
│ │ └── com
│ │ │ └── wisely
│ │ │ └── config
│ │ │ └── ConfigApplication.class
│ │ └── maven-status
│ │ └── maven-compiler-plugin
│ │ └── compile
│ │ └── default-compile
│ │ ├── createdFiles.lst
│ │ └── inputFiles.lst
├── discovery
│ ├── discovery.iml
│ ├── pom.xml
│ ├── src
│ │ └── main
│ │ │ ├── docker
│ │ │ ├── Dockerfile
│ │ │ └── runboot.sh
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── wisely
│ │ │ │ └── discovery
│ │ │ │ └── DiscoveryApplication.java
│ │ │ └── resources
│ │ │ └── application.yml
│ └── target
│ │ ├── classes
│ │ └── com
│ │ │ └── wisely
│ │ │ └── discovery
│ │ │ └── DiscoveryApplication.class
│ │ └── maven-status
│ │ └── maven-compiler-plugin
│ │ ├── compile
│ │ └── default-compile
│ │ │ ├── createdFiles.lst
│ │ │ └── inputFiles.lst
│ │ └── testCompile
│ │ └── default-testCompile
│ │ └── inputFiles.lst
├── docker-compose.yml
├── monitor
│ ├── monitor.iml
│ ├── pom.xml
│ ├── src
│ │ └── main
│ │ │ ├── docker
│ │ │ ├── Dockerfile
│ │ │ └── runboot.sh
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── wisely
│ │ │ │ └── monitor
│ │ │ │ └── MonitorApplication.java
│ │ │ └── resources
│ │ │ ├── application.yml
│ │ │ └── bootstrap.yml
│ └── target
│ │ ├── classes
│ │ └── com
│ │ │ └── wisely
│ │ │ └── monitor
│ │ │ └── MonitorApplication.class
│ │ └── maven-status
│ │ └── maven-compiler-plugin
│ │ ├── compile
│ │ └── default-compile
│ │ │ ├── createdFiles.lst
│ │ │ └── inputFiles.lst
│ │ └── testCompile
│ │ └── default-testCompile
│ │ └── inputFiles.lst
├── person
│ ├── person.iml
│ ├── pom.xml
│ ├── src
│ │ └── main
│ │ │ ├── docker
│ │ │ ├── Dockerfile
│ │ │ └── runboot.sh
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── wisely
│ │ │ │ └── person
│ │ │ │ ├── PersonApplication.java
│ │ │ │ ├── controller
│ │ │ │ └── PersonController.java
│ │ │ │ ├── dao
│ │ │ │ └── PersonRepository.java
│ │ │ │ └── domain
│ │ │ │ └── Person.java
│ │ │ └── resources
│ │ │ ├── application.yml
│ │ │ └── bootstrap.yml
│ └── target
│ │ ├── classes
│ │ └── com
│ │ │ └── wisely
│ │ │ └── person
│ │ │ ├── PersonApplication.class
│ │ │ ├── controller
│ │ │ └── PersonController.class
│ │ │ ├── dao
│ │ │ └── PersonRepository.class
│ │ │ └── domain
│ │ │ └── Person.class
│ │ └── maven-status
│ │ └── maven-compiler-plugin
│ │ ├── compile
│ │ └── default-compile
│ │ │ ├── createdFiles.lst
│ │ │ └── inputFiles.lst
│ │ └── testCompile
│ │ └── default-testCompile
│ │ └── inputFiles.lst
├── pom.xml
├── some
│ ├── pom.xml
│ ├── some.iml
│ ├── src
│ │ └── main
│ │ │ ├── docker
│ │ │ ├── Dockerfile
│ │ │ └── runboot.sh
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── wisely
│ │ │ │ └── some
│ │ │ │ └── SomeApplication.java
│ │ │ └── resources
│ │ │ ├── application.yml
│ │ │ └── bootstrap.yml
│ └── target
│ │ ├── classes
│ │ └── com
│ │ │ └── wisely
│ │ │ └── some
│ │ │ └── SomeApplication.class
│ │ └── maven-status
│ │ └── maven-compiler-plugin
│ │ ├── compile
│ │ └── default-compile
│ │ │ ├── createdFiles.lst
│ │ │ └── inputFiles.lst
│ │ └── testCompile
│ │ └── default-testCompile
│ │ └── inputFiles.lst
└── ui
│ ├── pom.xml
│ ├── src
│ └── main
│ │ ├── docker
│ │ ├── Dockerfile
│ │ └── runboot.sh
│ │ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ui
│ │ │ ├── UiApplication.java
│ │ │ ├── controller
│ │ │ └── UiController.java
│ │ │ ├── domain
│ │ │ └── Person.java
│ │ │ └── service
│ │ │ ├── PersonHystrixService.java
│ │ │ ├── PersonService.java
│ │ │ └── SomeHystrixService.java
│ │ └── resources
│ │ ├── application.yml
│ │ ├── bootstrap.yml
│ │ └── static
│ │ ├── css
│ │ └── application.css
│ │ ├── fonts
│ │ ├── glyphicons-halflings-regular.eot
│ │ ├── glyphicons-halflings-regular.svg
│ │ ├── glyphicons-halflings-regular.ttf
│ │ └── glyphicons-halflings-regular.woff
│ │ ├── index.html
│ │ ├── js
│ │ └── app.js
│ │ └── tpl
│ │ ├── person.html
│ │ └── some.html
│ ├── target
│ ├── classes
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ui
│ │ │ ├── UiApplication.class
│ │ │ ├── controller
│ │ │ └── UiController.class
│ │ │ ├── domain
│ │ │ └── Person.class
│ │ │ └── service
│ │ │ ├── PersonHystrixService.class
│ │ │ ├── PersonService.class
│ │ │ └── SomeHystrixService.class
│ └── maven-status
│ │ └── maven-compiler-plugin
│ │ ├── compile
│ │ └── default-compile
│ │ │ ├── createdFiles.lst
│ │ │ └── inputFiles.lst
│ │ └── testCompile
│ │ └── default-testCompile
│ │ └── inputFiles.lst
│ └── ui.iml
├── ch5_2_2
├── ch5_2_2.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch5_2_2
│ │ │ └── Ch522Application.java
│ └── resources
│ │ ├── application.properties
│ │ ├── application.xx
│ │ └── banner.txt
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch5_2_2
│ └── Ch522ApplicationTests.java
├── ch5_2_3
├── ch5_2_3.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch5_2_3
│ │ │ └── Ch523Application.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch5_2_3
│ └── Ch523ApplicationTests.java
├── ch6_2_3
├── ch6_2_3.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch6_2_3
│ │ │ ├── Ch623Application.java
│ │ │ └── config
│ │ │ └── AuthorSettings.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch6_2_3
│ └── Ch623ApplicationTests.java
├── ch6_4
├── ch6_4.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch6_4
│ │ │ └── Ch64Application.java
│ └── resources
│ │ ├── application-dev.properties
│ │ ├── application-prod.properties
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch6_4
│ └── Ch64ApplicationTests.java
├── ch6_5
├── ch6_5.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch6_5
│ │ │ └── Ch65Application.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch6_5
│ └── Ch65ApplicationTests.java
├── ch7_2
├── ch7_2.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ ├── Ch72Application.java
│ │ │ ├── Person.java
│ │ │ └── WebMvcConfig.java
│ └── resources
│ │ ├── application.properties
│ │ ├── static
│ │ ├── bootstrap
│ │ │ ├── css
│ │ │ │ ├── bootstrap-theme.css
│ │ │ │ ├── bootstrap-theme.css.map
│ │ │ │ ├── bootstrap-theme.min.css
│ │ │ │ ├── bootstrap.css
│ │ │ │ ├── bootstrap.css.map
│ │ │ │ └── bootstrap.min.css
│ │ │ ├── fonts
│ │ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ │ ├── glyphicons-halflings-regular.svg
│ │ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ │ ├── glyphicons-halflings-regular.woff
│ │ │ │ └── glyphicons-halflings-regular.woff2
│ │ │ └── js
│ │ │ │ ├── bootstrap.js
│ │ │ │ ├── bootstrap.min.js
│ │ │ │ └── npm.js
│ │ ├── jquery-1.10.2.min.js
│ │ └── jquery-1.10.2.min.map
│ │ └── templates
│ │ └── index.html
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── Ch72ApplicationTests.java
├── ch7_4
├── .keystore
├── ch7_4.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch7_4
│ │ │ ├── Ch74Application.java
│ │ │ └── CustomServletContainer.java
│ └── resources
│ │ ├── application.properties
│ │ └── static
│ │ ├── 404.html
│ │ ├── favicon.ico
│ │ └── index.html
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch7_4
│ └── Ch74ApplicationTests.java
├── ch7_6
├── ch7_6.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch7_6
│ │ │ ├── Ch76Application.java
│ │ │ ├── WebMvcConfig.java
│ │ │ ├── WebSecurityConfig.java
│ │ │ ├── WebSocketConfig.java
│ │ │ ├── domain
│ │ │ ├── WiselyMessage.java
│ │ │ └── WiselyResponse.java
│ │ │ └── web
│ │ │ └── WsController.java
│ └── resources
│ │ ├── application.properties
│ │ ├── static
│ │ ├── jquery.js
│ │ ├── sockjs.min.js
│ │ └── stomp.min.js
│ │ └── templates
│ │ ├── chat.html
│ │ ├── login.html
│ │ └── ws.html
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch7_6
│ └── Ch76ApplicationTests.java
├── ch7_7
├── ch7_7.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch7_7
│ │ │ ├── Ch77Application.java
│ │ │ └── Person.java
│ └── resources
│ │ ├── application.properties
│ │ └── static
│ │ ├── action.html
│ │ ├── angularjs.html
│ │ ├── bootstrap.html
│ │ ├── bootstrap
│ │ ├── css
│ │ │ ├── bootstrap-theme.css
│ │ │ ├── bootstrap-theme.css.map
│ │ │ ├── bootstrap-theme.min.css
│ │ │ ├── bootstrap.css
│ │ │ ├── bootstrap.css.map
│ │ │ └── bootstrap.min.css
│ │ ├── fonts
│ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ ├── glyphicons-halflings-regular.svg
│ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ ├── glyphicons-halflings-regular.woff
│ │ │ └── glyphicons-halflings-regular.woff2
│ │ └── js
│ │ │ ├── bootstrap.js
│ │ │ ├── bootstrap.min.js
│ │ │ └── npm.js
│ │ ├── jqueryui
│ │ ├── images
│ │ │ ├── ui-bg_diagonals-thick_18_b81900_40x40.png
│ │ │ ├── ui-bg_diagonals-thick_20_666666_40x40.png
│ │ │ ├── ui-bg_flat_10_000000_40x100.png
│ │ │ ├── ui-bg_glass_100_f6f6f6_1x400.png
│ │ │ ├── ui-bg_glass_100_fdf5ce_1x400.png
│ │ │ ├── ui-bg_glass_65_ffffff_1x400.png
│ │ │ ├── ui-bg_gloss-wave_35_f6a828_500x100.png
│ │ │ ├── ui-bg_highlight-soft_100_eeeeee_1x100.png
│ │ │ ├── ui-bg_highlight-soft_75_ffe45c_1x100.png
│ │ │ ├── ui-icons_222222_256x240.png
│ │ │ ├── ui-icons_228ef1_256x240.png
│ │ │ ├── ui-icons_ef8c08_256x240.png
│ │ │ ├── ui-icons_ffd27a_256x240.png
│ │ │ └── ui-icons_ffffff_256x240.png
│ │ ├── jquery-ui.min.css
│ │ └── jquery-ui.min.js
│ │ ├── js-action
│ │ ├── app.js
│ │ ├── controllers.js
│ │ ├── directives.js
│ │ └── services.js
│ │ ├── js
│ │ ├── angular-route.min.js
│ │ ├── angular.min.js
│ │ ├── html5shiv.min.js
│ │ ├── jquery.min.js
│ │ └── respond.min.js
│ │ └── views
│ │ ├── view1.html
│ │ └── view2.html
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch7_7
│ └── Ch77ApplicationTests.java
├── ch8_2
├── ch8_2.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ ├── Ch82Application.java
│ │ │ ├── dao
│ │ │ └── PersonRepository.java
│ │ │ ├── domain
│ │ │ └── Person.java
│ │ │ ├── specs
│ │ │ └── CustomerSpecs.java
│ │ │ ├── support
│ │ │ ├── CustomRepository.java
│ │ │ ├── CustomRepositoryFactoryBean.java
│ │ │ └── CustomRepositoryImpl.java
│ │ │ └── web
│ │ │ └── DataController.java
│ └── resources
│ │ ├── application.properties
│ │ └── data.sql
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── Ch82ApplicationTests.java
├── ch8_3
├── ch8_3.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch8_3
│ │ │ ├── Ch83Application.java
│ │ │ ├── dao
│ │ │ └── PersonRepository.java
│ │ │ └── domain
│ │ │ └── Person.java
│ └── resources
│ │ ├── application.properties
│ │ ├── data--.sql
│ │ └── postman.crx
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch8_3
│ └── Ch83ApplicationTests.java
├── ch8_4
├── ch8_4.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch8_4
│ │ │ ├── Ch84Application.java
│ │ │ ├── dao
│ │ │ └── PersonRepository.java
│ │ │ ├── domain
│ │ │ └── Person.java
│ │ │ ├── service
│ │ │ ├── DemoService.java
│ │ │ └── impl
│ │ │ │ └── DemoServiceImpl.java
│ │ │ └── web
│ │ │ └── MyController.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch8_4
│ └── Ch84ApplicationTests.java
├── ch8_5
├── ch8_5.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch8_5
│ │ │ ├── AppConfig.java
│ │ │ ├── Ch85Application.java
│ │ │ ├── dao
│ │ │ └── PersonRepository.java
│ │ │ ├── domain
│ │ │ └── Person.java
│ │ │ ├── service
│ │ │ ├── DemoService.java
│ │ │ └── impl
│ │ │ │ └── DemoServiceImpl.java
│ │ │ └── web
│ │ │ └── CacheController.java
│ └── resources
│ │ ├── application.properties
│ │ └── ehcache.xml
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch8_5
│ └── Ch85ApplicationTests.java
├── ch8_6_1
├── ch8_6_1.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch8_6_1
│ │ │ ├── Ch861Application.java
│ │ │ ├── dao
│ │ │ └── PersonRepository.java
│ │ │ ├── domain
│ │ │ ├── Location.java
│ │ │ └── Person.java
│ │ │ └── web
│ │ │ └── DataController.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch8_6_1
│ └── Ch861ApplicationTests.java
├── ch8_6_2
├── ch8_6_2.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch8_6_2
│ │ │ ├── Ch862Application.java
│ │ │ ├── dao
│ │ │ └── Person.java
│ │ │ ├── domain
│ │ │ └── PersonDao.java
│ │ │ └── web
│ │ │ └── DataController.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch8_6_2
│ └── Ch862ApplicationTests.java
├── ch9_1
├── ch9_1.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch9_1
│ │ │ ├── Ch91Application.java
│ │ │ ├── config
│ │ │ ├── WebMvcConfig.java
│ │ │ └── WebSecurityConfig.java
│ │ │ ├── dao
│ │ │ └── SysUserRepository.java
│ │ │ ├── domain
│ │ │ ├── Msg.java
│ │ │ ├── SysRole.java
│ │ │ └── SysUser.java
│ │ │ ├── security
│ │ │ └── CustomUserService.java
│ │ │ └── web
│ │ │ └── HomeController.java
│ └── resources
│ │ ├── application.properties
│ │ ├── data--.sql
│ │ ├── static
│ │ └── css
│ │ │ └── bootstrap.min.css
│ │ └── templates
│ │ ├── home.html
│ │ └── login.html
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch9_1
│ └── Ch91ApplicationTests.java
├── ch9_2
├── ch9_2.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch9_2
│ │ │ ├── Ch92Application.java
│ │ │ ├── batch
│ │ │ ├── CsvBatchConfig.java
│ │ │ ├── CsvBeanValidator.java
│ │ │ ├── CsvItemProcessor.java
│ │ │ ├── CsvJobListener.java
│ │ │ └── TriggerBatchConfig.java
│ │ │ ├── domain
│ │ │ └── Person.java
│ │ │ └── web
│ │ │ └── DemoController.java
│ └── resources
│ │ ├── application.properties
│ │ ├── people.csv
│ │ └── schema.sql
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch9_2
│ └── Ch92ApplicationTests.java
├── ch9_3_4
├── ch9_3_4.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch9_3_4
│ │ │ ├── Ch934Application.java
│ │ │ ├── Msg.java
│ │ │ └── Receiver.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch9_3_4
│ └── Ch934ApplicationTests.java
├── ch9_3_5
├── ch9_3_5.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch9_3_5
│ │ │ ├── Ch935Application.java
│ │ │ └── Receiver.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch9_3_5
│ └── Ch935ApplicationTests.java
├── ch9_4
├── ch9_4.iml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── wisely
│ │ │ └── ch9_4
│ │ │ └── Ch94Application.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── ch9_4
│ └── Ch94ApplicationTests.java
├── highlight_spring4
├── highlight_spring4.iml
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── wisely
│ │ └── highlight_spring4
│ │ ├── ch1
│ │ ├── aop
│ │ │ ├── Action.java
│ │ │ ├── AopConfig.java
│ │ │ ├── DemoAnnotationService.java
│ │ │ ├── DemoMethodService.java
│ │ │ ├── LogAspect.java
│ │ │ └── Main.java
│ │ ├── di
│ │ │ ├── DiConfig.java
│ │ │ ├── FunctionService.java
│ │ │ ├── Main.java
│ │ │ └── UseFunctionService.java
│ │ └── javaconfig
│ │ │ ├── FunctionService.java
│ │ │ ├── JavaConfig.java
│ │ │ ├── Main.java
│ │ │ └── UseFunctionService.java
│ │ ├── ch2
│ │ ├── el
│ │ │ ├── DemoService.java
│ │ │ ├── ElConfig.java
│ │ │ ├── Main.java
│ │ │ ├── test.properties
│ │ │ └── test.txt
│ │ ├── event
│ │ │ ├── DemoEvent.java
│ │ │ ├── DemoListener.java
│ │ │ ├── DemoPublisher.java
│ │ │ ├── EventConfig.java
│ │ │ └── Main.java
│ │ ├── prepost
│ │ │ ├── BeanWayService.java
│ │ │ ├── JSR250WayService.java
│ │ │ ├── Main.java
│ │ │ └── PrePostConfig.java
│ │ ├── profile
│ │ │ ├── DemoBean.java
│ │ │ ├── Main.java
│ │ │ └── ProfileConfig.java
│ │ └── scope
│ │ │ ├── DemoPrototypeService.java
│ │ │ ├── DemoSingletonService.java
│ │ │ ├── Main.java
│ │ │ └── ScopeConfig.java
│ │ └── ch3
│ │ ├── annotation
│ │ ├── DemoConfig.java
│ │ ├── DemoService.java
│ │ ├── Main.java
│ │ └── WiselyConfiguration.java
│ │ ├── aware
│ │ ├── AwareConfig.java
│ │ ├── AwareService.java
│ │ ├── Main.java
│ │ └── test.txt
│ │ ├── conditional
│ │ ├── ConditionConifg.java
│ │ ├── LinuxCondition.java
│ │ ├── LinuxListService.java
│ │ ├── ListService.java
│ │ ├── Main.java
│ │ ├── WindowsCondition.java
│ │ └── WindowsListService.java
│ │ ├── fortest
│ │ ├── TestBean.java
│ │ └── TestConfig.java
│ │ ├── taskexecutor
│ │ ├── AsyncTaskService.java
│ │ ├── Main.java
│ │ └── TaskExecutorConfig.java
│ │ └── taskscheduler
│ │ ├── Main.java
│ │ ├── ScheduledTaskService.java
│ │ └── TaskSchedulerConfig.java
│ └── test
│ └── java
│ └── com
│ └── wisely
│ └── highlight_spring4
│ └── ch3
│ └── fortest
│ └── DemoBeanIntegrationTests.java
└── highlight_springmvc4
├── highlight_springmvc4.iml
├── pom.xml
└── src
├── main
├── java
│ └── com
│ │ └── wisely
│ │ └── highlight_springmvc4
│ │ ├── MyMvcConfig.java
│ │ ├── WebInitializer.java
│ │ ├── advice
│ │ └── ExceptionHandlerAdvice.java
│ │ ├── domain
│ │ └── DemoObj.java
│ │ ├── interceptor
│ │ └── DemoInterceptor.java
│ │ ├── messageconverter
│ │ └── MyMessageConverter.java
│ │ ├── service
│ │ ├── DemoService.java
│ │ └── PushService.java
│ │ └── web
│ │ ├── HelloController.java
│ │ ├── ch4_3
│ │ ├── DemoAnnoController.java
│ │ └── DemoRestController.java
│ │ ├── ch4_4
│ │ └── AdviceController.java
│ │ ├── ch4_5
│ │ ├── AysncController.java
│ │ ├── ContentController.java
│ │ ├── ConverterController.java
│ │ ├── SseController.java
│ │ └── UploadController.java
│ │ └── ch4_6
│ │ ├── MyRestController.java
│ │ └── NormalController.java
└── resources
│ ├── assets
│ └── js
│ │ └── jquery.js
│ ├── logback.xml
│ └── views
│ ├── async.jsp
│ ├── converter.jsp
│ ├── error.jsp
│ ├── index.jsp
│ ├── page.jsp
│ ├── sse.jsp
│ └── upload.jsp
└── test
└── java
└── com
└── wisely
└── highlight_springmvc4
└── web
└── ch4_6
└── TestControllerIntegrationTests.java
/README.md:
--------------------------------------------------------------------------------
1 | # springboot-wyf-sourcecode
2 | 《Spring Boot 实战》示例源码(作者:汪云飞)
3 |
--------------------------------------------------------------------------------
/ch10/src/main/java/com/wisely/ch10/Ch10Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch10;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Ch10Application{
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(Ch10Application.class, args);
11 | }
12 |
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/ch10/src/main/java/com/wisely/ch10/DemoController.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch10;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 |
6 | @Controller
7 | public class DemoController {
8 | @RequestMapping("/")
9 | public String index(){
10 | return "index";
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/ch10/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #spring.thymeleaf.cache=false
--------------------------------------------------------------------------------
/ch10/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | test
6 |
7 |
8 |
9 |
10 | 123456111222
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/ch10/src/test/java/com/wisely/ch10/Ch10ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch10;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch10Application.class)
11 | @WebAppConfiguration
12 | public class Ch10ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch10_4/src/main/java/com/wisely/ch10_4/Ch104Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch10_4;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Ch104Application {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(Ch104Application.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch10_4/src/main/java/com/wisely/ch10_4/dao/PersonRepository.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch10_4.dao;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | import com.wisely.ch10_4.domain.Person;
6 |
7 | public interface PersonRepository extends JpaRepository {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/ch10_4/src/main/java/com/wisely/ch10_4/domain/Person.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch10_4.domain;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Person {
9 | @Id
10 | @GeneratedValue
11 | private Long id;
12 | private String name;
13 |
14 | public Person() {
15 | super();
16 | }
17 | public Person(String name) {
18 | super();
19 | this.name = name;
20 | }
21 | public Long getId() {
22 | return id;
23 | }
24 | public void setId(Long id) {
25 | this.id = id;
26 | }
27 | public String getName() {
28 | return name;
29 | }
30 | public void setName(String name) {
31 | this.name = name;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/ch10_4/src/main/java/com/wisely/ch10_4/web/PersonController.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch10_4.web;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.http.MediaType;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestMethod;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | import com.wisely.ch10_4.dao.PersonRepository;
12 | import com.wisely.ch10_4.domain.Person;
13 |
14 | @RestController
15 | @RequestMapping("/person")
16 | public class PersonController {
17 | @Autowired
18 | PersonRepository personRepository;
19 |
20 | @RequestMapping(method = RequestMethod.GET,produces = {MediaType.APPLICATION_JSON_VALUE} )
21 | public List findAll(){
22 | return personRepository.findAll();
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/ch10_4/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch10_4/src/main/resources/application.properties
--------------------------------------------------------------------------------
/ch10docker/src/main/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM java:8
2 |
3 | MAINTAINER wyf
4 |
5 | ADD ch10docker-0.0.1-SNAPSHOT.jar app.jar
6 |
7 | EXPOSE 8080
8 |
9 | ENTRYPOINT ["java","-jar","/app.jar"]
--------------------------------------------------------------------------------
/ch10docker/src/main/java/com/wisely/Ch10dockerApplication.java:
--------------------------------------------------------------------------------
1 | package com.wisely;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RestController;
7 |
8 | @SpringBootApplication
9 | @RestController
10 | public class Ch10dockerApplication {
11 | @RequestMapping("/")
12 | public String home() {
13 | return "Hello Docker!!";
14 | }
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(Ch10dockerApplication.class, args);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch10docker/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch10docker/src/main/resources/application.properties
--------------------------------------------------------------------------------
/ch10docker/src/test/java/com/wisely/Ch10dockerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch10dockerApplication.class)
11 | @WebAppConfiguration
12 | public class Ch10dockerApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch10war/src/main/java/com/wisely/ch10war/Ch10warApplication.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch10war;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Ch10warApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(Ch10warApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch10war/src/main/java/com/wisely/ch10war/DemoController.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch10war;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 |
6 | @Controller
7 | public class DemoController {
8 | @RequestMapping("/")
9 | public String index(){
10 | return "index";
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/ch10war/src/main/java/com/wisely/ch10war/ServletInitializer.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch10war;
2 |
3 | import org.springframework.boot.builder.SpringApplicationBuilder;
4 | import org.springframework.boot.context.web.SpringBootServletInitializer;
5 |
6 | public class ServletInitializer extends SpringBootServletInitializer {
7 |
8 | @Override
9 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
10 | return application.sources(Ch10warApplication.class);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/ch10war/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch10war/src/main/resources/application.properties
--------------------------------------------------------------------------------
/ch10war/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | test
6 |
7 |
8 |
9 |
10 | 123456111222
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/ch10war/src/test/java/com/wisely/ch10war/Ch10warApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch10war;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch10warApplication.class)
11 | @WebAppConfiguration
12 | public class Ch10warApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch11_1/src/main/java/com/wisely/ch11_1/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch11_1;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.actuate.endpoint.Endpoint;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @RestController
13 | public class DemoApplication {
14 | @Autowired
15 | StatusService statusService;
16 |
17 | public static void main(String[] args) {
18 | SpringApplication.run(DemoApplication.class, args);
19 | }
20 |
21 | @Bean
22 | public Endpoint status() {
23 | Endpoint status = new StatusEndPoint();
24 | return status;
25 | }
26 | @RequestMapping("/change")
27 | public String changeStatus(String status){
28 | statusService.setStatus(status);
29 | return "OK";
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ch11_1/src/main/java/com/wisely/ch11_1/StatusEndPoint.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch11_1;
2 |
3 | import org.springframework.beans.BeansException;
4 | import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
5 | import org.springframework.boot.context.properties.ConfigurationProperties;
6 | import org.springframework.context.ApplicationContext;
7 | import org.springframework.context.ApplicationContextAware;
8 |
9 |
10 | @ConfigurationProperties(prefix = "endpoints.status", ignoreUnknownFields = false) //1
11 | public class StatusEndPoint extends AbstractEndpoint implements ApplicationContextAware{//2
12 |
13 | ApplicationContext context;
14 |
15 | public StatusEndPoint() {
16 | super("status");
17 | }
18 |
19 | @Override
20 | public String invoke() { //3
21 | StatusService statusService = context.getBean(StatusService.class);
22 |
23 | return "The Current Status is :"+statusService.getStatus();
24 | }
25 |
26 | @Override
27 | public void setApplicationContext(ApplicationContext arg0) throws BeansException {
28 | this.context = arg0;
29 |
30 | }
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/ch11_1/src/main/java/com/wisely/ch11_1/StatusHealth.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch11_1;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.boot.actuate.health.Health;
5 | import org.springframework.boot.actuate.health.HealthIndicator;
6 | import org.springframework.stereotype.Component;
7 | @Component
8 | public class StatusHealth implements HealthIndicator {//1
9 | @Autowired
10 | StatusService statusService;
11 |
12 | @Override
13 | public Health health() {
14 | String status = statusService.getStatus();
15 | if(status == null||!status.equals("running")){
16 | return Health.down().withDetail("Error", "Not Running").build(); //2
17 | }
18 | return Health.up().build(); //3
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/ch11_1/src/main/java/com/wisely/ch11_1/StatusService.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch11_1;
2 |
3 | import org.springframework.stereotype.Service;
4 |
5 | @Service
6 | public class StatusService {
7 |
8 | private String status;
9 |
10 | public String getStatus() {
11 | return status;
12 | }
13 |
14 | public void setStatus(String status) {
15 | this.status = status;
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/ch11_1/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | endpoints.shutdown.enabled=true
2 | #endpoints.beans.id=mybeans
3 | #endpoints.beans.enabled=false
4 | #endpoints.enabled=false
5 | #endpoints.beans.enabled=true
6 | #management.context-path=/manage
7 | #management.port=8081
8 | #management.port=-1
9 |
--------------------------------------------------------------------------------
/ch11_1/src/test/java/com/wisely/ch12_1/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch12_1;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 |
7 | import com.wisely.ch11_1.DemoApplication;
8 |
9 | import org.springframework.boot.test.SpringApplicationConfiguration;
10 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
11 |
12 | @RunWith(SpringJUnit4ClassRunner.class)
13 | @SpringApplicationConfiguration(classes = DemoApplication.class)
14 | @WebAppConfiguration
15 | public class DemoApplicationTests {
16 |
17 | @Test
18 | public void contextLoads() {
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/ch11_3/src/main/java/com/wisely/ch11_3/Ch123Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch11_3;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Ch123Application {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(Ch123Application.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch11_3/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | shell.auth.simple.user.name=wyf
2 | shell.auth.simple.user.password=wyf
3 |
--------------------------------------------------------------------------------
/ch11_3/src/main/resources/commands/hello.groovy:
--------------------------------------------------------------------------------
1 | package commands
2 | import org.crsh.cli.Command
3 | import org.crsh.cli.Usage
4 | import org.crsh.command.InvocationContext
5 | class hello {
6 | @Usage("Say Hello")
7 | @Command
8 | def main(InvocationContext context) {
9 |
10 | def bootVersion = context.attributes['spring.boot.version'];
11 | def springVersion = context.attributes['spring.version']
12 |
13 | return "Hello,your Spring Boot version is "+bootVersion +",your Spring Framework version is "+springVersion
14 |
15 | }
16 | }
--------------------------------------------------------------------------------
/ch11_3/src/test/java/com/wisely/ch12_3/Ch123ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch12_3;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | import com.wisely.ch11_3.Ch123Application;
9 |
10 | @RunWith(SpringJUnit4ClassRunner.class)
11 | @SpringApplicationConfiguration(classes = Ch123Application.class)
12 | public class Ch123ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch12/config/src/main/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM java:8
2 | VOLUME /tmp
3 | RUN mkdir /app
4 | ADD config-1.0.0-SNAPSHOT.jar /app/app.jar
5 | ADD runboot.sh /app/
6 | RUN bash -c 'touch /app/app.jar'
7 | WORKDIR /app
8 | RUN chmod a+x runboot.sh
9 | EXPOSE 8888
10 | CMD /app/runboot.sh
--------------------------------------------------------------------------------
/ch12/config/src/main/docker/runboot.sh:
--------------------------------------------------------------------------------
1 | sleep 10
2 | java -Djava.security.egd=file:/dev/./urandom -jar /app/app.jar
--------------------------------------------------------------------------------
/ch12/config/src/main/java/com/wisely/config/ConfigApplication.java:
--------------------------------------------------------------------------------
1 | package com.wisely.config;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 |
8 | @SpringBootApplication
9 | @EnableConfigServer //1
10 | @EnableEurekaClient //2
11 | public class ConfigApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(ConfigApplication.class, args);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/ch12/config/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | cloud:
3 | config:
4 | server:
5 | native:
6 | search-locations: classpath:/config #1
7 |
8 | server:
9 | port: 8888
10 |
--------------------------------------------------------------------------------
/ch12/config/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: config #1
4 | profiles:
5 | active: native #2
6 |
7 | eureka:
8 | instance:
9 | non-secure-port: ${server.port:8888} #3
10 | metadata-map:
11 | instanceId: ${spring.application.name}:${random.value} #4
12 | client:
13 | service-url:
14 | defaultZone: http://${eureka.host:localhost}:${eureka.port:8761}/eureka/ #5
15 |
16 |
--------------------------------------------------------------------------------
/ch12/config/src/main/resources/config/person-docker.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | jpa:
3 | database: POSTGRESQL
4 | datasource:
5 | platform: postgres
6 | url: jdbc:postgresql://postgres:5432/postgres
7 | username: postgres
8 | password: postgres
9 | driver-class-name: org.postgresql.Driver
--------------------------------------------------------------------------------
/ch12/config/src/main/resources/config/person.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | jpa:
3 | database: HSQL
--------------------------------------------------------------------------------
/ch12/config/src/main/resources/config/some-docker.yml:
--------------------------------------------------------------------------------
1 | my:
2 | message: Message from Production
--------------------------------------------------------------------------------
/ch12/config/src/main/resources/config/some.yml:
--------------------------------------------------------------------------------
1 | my:
2 | message: Message from Development
3 |
--------------------------------------------------------------------------------
/ch12/config/target/classes/com/wisely/config/ConfigApplication.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/config/target/classes/com/wisely/config/ConfigApplication.class
--------------------------------------------------------------------------------
/ch12/config/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst:
--------------------------------------------------------------------------------
1 | com/wisely/config/ConfigApplication.class
2 |
--------------------------------------------------------------------------------
/ch12/config/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst:
--------------------------------------------------------------------------------
1 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/config/src/main/java/com/wisely/config/ConfigApplication.java
2 |
--------------------------------------------------------------------------------
/ch12/discovery/src/main/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM java:8
2 | VOLUME /tmp
3 | RUN mkdir /app
4 | ADD discovery-1.0.0-SNAPSHOT.jar /app/app.jar
5 | ADD runboot.sh /app/
6 | RUN bash -c 'touch /app/app.jar'
7 | WORKDIR /app
8 | RUN chmod a+x runboot.sh
9 | EXPOSE 8761
10 | CMD /app/runboot.sh
--------------------------------------------------------------------------------
/ch12/discovery/src/main/docker/runboot.sh:
--------------------------------------------------------------------------------
1 | java -Djava.security.egd=file:/dev/./urandom -jar /app/app.jar
--------------------------------------------------------------------------------
/ch12/discovery/src/main/java/com/wisely/discovery/DiscoveryApplication.java:
--------------------------------------------------------------------------------
1 | package com.wisely.discovery;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @SpringBootApplication
8 | @EnableEurekaServer //1
9 | public class DiscoveryApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DiscoveryApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/ch12/discovery/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8761
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | register-with-eureka: false
9 | fetch-registry: false
10 |
--------------------------------------------------------------------------------
/ch12/discovery/target/classes/com/wisely/discovery/DiscoveryApplication.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/discovery/target/classes/com/wisely/discovery/DiscoveryApplication.class
--------------------------------------------------------------------------------
/ch12/discovery/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst:
--------------------------------------------------------------------------------
1 | com/wisely/discovery/DiscoveryApplication.class
2 |
--------------------------------------------------------------------------------
/ch12/discovery/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst:
--------------------------------------------------------------------------------
1 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/discovery/src/main/java/com/wisely/discovery/DiscoveryApplication.java
2 |
--------------------------------------------------------------------------------
/ch12/discovery/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/discovery/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
--------------------------------------------------------------------------------
/ch12/monitor/src/main/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM java:8
2 | VOLUME /tmp
3 | RUN mkdir /app
4 | ADD monitor-1.0.0-SNAPSHOT.jar /app/app.jar
5 | ADD runboot.sh /app/
6 | RUN bash -c 'touch /app/app.jar'
7 | WORKDIR /app
8 | RUN chmod a+x runboot.sh
9 | EXPOSE 8989
10 | CMD /app/runboot.sh
--------------------------------------------------------------------------------
/ch12/monitor/src/main/docker/runboot.sh:
--------------------------------------------------------------------------------
1 | sleep 100
2 | java -Djava.security.egd=file:/dev/./urandom -jar /app/app.jar
--------------------------------------------------------------------------------
/ch12/monitor/src/main/java/com/wisely/monitor/MonitorApplication.java:
--------------------------------------------------------------------------------
1 | package com.wisely.monitor;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
7 | import org.springframework.cloud.netflix.turbine.EnableTurbine;
8 |
9 | @SpringBootApplication
10 | @EnableEurekaClient
11 | @EnableHystrixDashboard
12 | @EnableTurbine
13 | public class MonitorApplication {
14 |
15 | public static void main(String[] args) {
16 | SpringApplication.run(MonitorApplication.class, args);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ch12/monitor/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8989
3 |
4 |
--------------------------------------------------------------------------------
/ch12/monitor/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: monitor
4 |
5 | eureka:
6 | instance:
7 | nonSecurePort: ${server.port:8989}
8 | client:
9 | serviceUrl:
10 | defaultZone: http://${eureka.host:localhost}:${eureka.port:8761}/eureka/
--------------------------------------------------------------------------------
/ch12/monitor/target/classes/com/wisely/monitor/MonitorApplication.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/monitor/target/classes/com/wisely/monitor/MonitorApplication.class
--------------------------------------------------------------------------------
/ch12/monitor/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst:
--------------------------------------------------------------------------------
1 | com/wisely/monitor/MonitorApplication.class
2 |
--------------------------------------------------------------------------------
/ch12/monitor/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst:
--------------------------------------------------------------------------------
1 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/monitor/src/main/java/com/wisely/monitor/MonitorApplication.java
2 |
--------------------------------------------------------------------------------
/ch12/monitor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/monitor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
--------------------------------------------------------------------------------
/ch12/person/src/main/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM java:8
2 | VOLUME /tmp
3 | RUN mkdir /app
4 | ADD person-1.0.0-SNAPSHOT.jar /app/app.jar
5 | ADD runboot.sh /app/
6 | RUN bash -c 'touch /app/app.jar'
7 | WORKDIR /app
8 | RUN chmod a+x runboot.sh
9 | EXPOSE 8082
10 | CMD /app/runboot.sh
--------------------------------------------------------------------------------
/ch12/person/src/main/docker/runboot.sh:
--------------------------------------------------------------------------------
1 | sleep 90
2 | java -Djava.security.egd=file:/dev/./urandom -jar /app/app.jar
--------------------------------------------------------------------------------
/ch12/person/src/main/java/com/wisely/person/PersonApplication.java:
--------------------------------------------------------------------------------
1 | package com.wisely.person;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6 |
7 | @SpringBootApplication
8 | @EnableEurekaClient
9 | public class PersonApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(PersonApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/ch12/person/src/main/java/com/wisely/person/controller/PersonController.java:
--------------------------------------------------------------------------------
1 | package com.wisely.person.controller;
2 |
3 |
4 | import java.util.List;
5 |
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.data.domain.PageRequest;
8 | import org.springframework.web.bind.annotation.RequestBody;
9 | import org.springframework.web.bind.annotation.RequestMapping;
10 | import org.springframework.web.bind.annotation.RequestMethod;
11 | import org.springframework.web.bind.annotation.RestController;
12 |
13 | import com.wisely.person.dao.PersonRepository;
14 | import com.wisely.person.domain.Person;
15 |
16 | @RestController
17 | public class PersonController {
18 | @Autowired
19 | PersonRepository personRepository;
20 |
21 | @RequestMapping(value = "/save", method = RequestMethod.POST)
22 | public List savePerson(@RequestBody String personName) {
23 | Person p = new Person(personName);
24 | personRepository.save(p);
25 | List people = personRepository.findAll(new PageRequest(0, 10)).getContent();
26 | return people;
27 | }
28 |
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/ch12/person/src/main/java/com/wisely/person/dao/PersonRepository.java:
--------------------------------------------------------------------------------
1 | package com.wisely.person.dao;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | import com.wisely.person.domain.Person;
6 |
7 | public interface PersonRepository extends JpaRepository{
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/ch12/person/src/main/java/com/wisely/person/domain/Person.java:
--------------------------------------------------------------------------------
1 | package com.wisely.person.domain;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Person {
9 | @Id
10 | @GeneratedValue
11 | private Long id;
12 |
13 | private String name;
14 |
15 |
16 |
17 |
18 | public Person() {
19 | super();
20 | }
21 |
22 | public Person(String name) {
23 | super();
24 | this.name = name;
25 | }
26 |
27 | public Long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(Long id) {
32 | this.id = id;
33 | }
34 |
35 | public String getName() {
36 | return name;
37 | }
38 |
39 | public void setName(String name) {
40 | this.name = name;
41 | }
42 |
43 |
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/ch12/person/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8082
3 |
4 |
5 | spring:
6 | jpa:
7 | hibernate:
8 | ddl-auto: update
9 |
10 |
--------------------------------------------------------------------------------
/ch12/person/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: person
4 | cloud:
5 | config:
6 | enabled: true
7 | discovery:
8 | enabled: true
9 | service-id: CONFIG #1
10 | eureka:
11 | instance:
12 | non-secure-port: ${server.port:8082}
13 | client:
14 | service-url:
15 | defaultZone: http://${eureka.host:localhost}:${eureka.port:8761}/eureka/
--------------------------------------------------------------------------------
/ch12/person/target/classes/com/wisely/person/PersonApplication.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/person/target/classes/com/wisely/person/PersonApplication.class
--------------------------------------------------------------------------------
/ch12/person/target/classes/com/wisely/person/controller/PersonController.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/person/target/classes/com/wisely/person/controller/PersonController.class
--------------------------------------------------------------------------------
/ch12/person/target/classes/com/wisely/person/dao/PersonRepository.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/person/target/classes/com/wisely/person/dao/PersonRepository.class
--------------------------------------------------------------------------------
/ch12/person/target/classes/com/wisely/person/domain/Person.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/person/target/classes/com/wisely/person/domain/Person.class
--------------------------------------------------------------------------------
/ch12/person/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst:
--------------------------------------------------------------------------------
1 | com/wisely/person/dao/PersonRepository.class
2 | com/wisely/person/domain/Person.class
3 | com/wisely/person/controller/PersonController.class
4 | com/wisely/person/PersonApplication.class
5 |
--------------------------------------------------------------------------------
/ch12/person/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst:
--------------------------------------------------------------------------------
1 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/person/src/main/java/com/wisely/person/domain/Person.java
2 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/person/src/main/java/com/wisely/person/controller/PersonController.java
3 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/person/src/main/java/com/wisely/person/dao/PersonRepository.java
4 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/person/src/main/java/com/wisely/person/PersonApplication.java
5 |
--------------------------------------------------------------------------------
/ch12/person/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/person/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
--------------------------------------------------------------------------------
/ch12/some/src/main/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM java:8
2 | VOLUME /tmp
3 | RUN mkdir /app
4 | ADD some-1.0.0-SNAPSHOT.jar /app/app.jar
5 | ADD runboot.sh /app/
6 | RUN bash -c 'touch /app/app.jar'
7 | WORKDIR /app
8 | RUN chmod a+x runboot.sh
9 | EXPOSE 8083
10 | CMD /app/runboot.sh
--------------------------------------------------------------------------------
/ch12/some/src/main/docker/runboot.sh:
--------------------------------------------------------------------------------
1 | sleep 90
2 | java -Djava.security.egd=file:/dev/./urandom -jar /app/app.jar
--------------------------------------------------------------------------------
/ch12/some/src/main/java/com/wisely/some/SomeApplication.java:
--------------------------------------------------------------------------------
1 | package com.wisely.some;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | @SpringBootApplication
11 | @EnableDiscoveryClient
12 | @RestController
13 | public class SomeApplication {
14 | @Value("${my.message}") //1
15 | private String message;
16 |
17 | @RequestMapping(value = "/getsome")
18 | public String getsome(){
19 | return message;
20 | }
21 | public static void main(String[] args) {
22 | SpringApplication.run(SomeApplication.class, args);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/ch12/some/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8083
3 |
--------------------------------------------------------------------------------
/ch12/some/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: some
4 | cloud:
5 | config:
6 | enabled: true
7 | discovery:
8 | enabled: true
9 | service-id: CONFIG
10 | eureka:
11 | instance:
12 | non-secure-port: ${server.port:8083}
13 | client:
14 | service-url:
15 | defaultZone: http://${eureka.host:localhost}:${eureka.port:8761}/eureka/
--------------------------------------------------------------------------------
/ch12/some/target/classes/com/wisely/some/SomeApplication.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/some/target/classes/com/wisely/some/SomeApplication.class
--------------------------------------------------------------------------------
/ch12/some/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst:
--------------------------------------------------------------------------------
1 | com/wisely/some/SomeApplication.class
2 |
--------------------------------------------------------------------------------
/ch12/some/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst:
--------------------------------------------------------------------------------
1 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/some/src/main/java/com/wisely/some/SomeApplication.java
2 |
--------------------------------------------------------------------------------
/ch12/some/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/some/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
--------------------------------------------------------------------------------
/ch12/ui/src/main/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM java:8
2 | VOLUME /tmp
3 | RUN mkdir /app
4 | ADD ui-1.0.0-SNAPSHOT.jar /app/app.jar
5 | ADD runboot.sh /app/
6 | RUN bash -c 'touch /app/app.jar'
7 | WORKDIR /app
8 | RUN chmod a+x runboot.sh
9 | EXPOSE 80
10 | CMD /app/runboot.sh
--------------------------------------------------------------------------------
/ch12/ui/src/main/docker/runboot.sh:
--------------------------------------------------------------------------------
1 | sleep 10
2 | java -Djava.security.egd=file:/dev/./urandom -jar /app/app.jar
--------------------------------------------------------------------------------
/ch12/ui/src/main/java/com/wisely/ui/UiApplication.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ui;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 | import org.springframework.cloud.netflix.feign.EnableFeignClients;
8 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
9 |
10 | @SpringBootApplication
11 | @EnableEurekaClient
12 | @EnableFeignClients //1
13 | @EnableCircuitBreaker //2
14 | @EnableZuulProxy //3
15 | public class UiApplication {
16 | public static void main(String[] args) {
17 | SpringApplication.run(UiApplication.class, args);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch12/ui/src/main/java/com/wisely/ui/controller/UiController.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ui.controller;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.http.MediaType;
7 | import org.springframework.web.bind.annotation.RequestBody;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | import com.wisely.ui.domain.Person;
12 | import com.wisely.ui.service.PersonHystrixService;
13 | import com.wisely.ui.service.SomeHystrixService;
14 |
15 | @RestController
16 | public class UiController {
17 | @Autowired
18 | private SomeHystrixService someHystrixService;
19 |
20 | @Autowired
21 | private PersonHystrixService personHystrixService;
22 |
23 | @RequestMapping("/dispatch")
24 | public List sendMessage(@RequestBody String personName) {
25 | return personHystrixService.save(personName);
26 | }
27 |
28 | @RequestMapping(value = "/getsome",produces={MediaType.TEXT_PLAIN_VALUE})
29 | public String getSome(){
30 | return someHystrixService.getSome();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/ch12/ui/src/main/java/com/wisely/ui/domain/Person.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ui.domain;
2 |
3 |
4 | public class Person {
5 | private Long id;
6 |
7 | private String name;
8 |
9 |
10 | public Person() {
11 | super();
12 | }
13 |
14 | public Person(String name) {
15 | super();
16 | this.name = name;
17 | }
18 |
19 | public Long getId() {
20 | return id;
21 | }
22 |
23 | public void setId(Long id) {
24 | this.id = id;
25 | }
26 |
27 | public String getName() {
28 | return name;
29 | }
30 |
31 | public void setName(String name) {
32 | this.name = name;
33 | }
34 |
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/ch12/ui/src/main/java/com/wisely/ui/service/PersonHystrixService.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ui.service;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
9 | import com.wisely.ui.domain.Person;
10 |
11 | @Service
12 | public class PersonHystrixService {
13 |
14 | @Autowired
15 | PersonService personService;
16 |
17 | @HystrixCommand(fallbackMethod = "fallbackSave") //1
18 | public List save(String name) {
19 | return personService.save(name);
20 | }
21 |
22 | public List fallbackSave(String name){
23 | List list = new ArrayList<>();
24 | Person p = new Person(name+"没有保存成功,Person Service 故障");
25 | list.add(p);
26 | return list;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ch12/ui/src/main/java/com/wisely/ui/service/PersonService.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ui.service;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.cloud.netflix.feign.FeignClient;
6 | import org.springframework.http.MediaType;
7 | import org.springframework.web.bind.annotation.RequestBody;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RequestMethod;
10 | import org.springframework.web.bind.annotation.ResponseBody;
11 |
12 | import com.wisely.ui.domain.Person;
13 |
14 | @FeignClient("person")
15 | public interface PersonService {
16 | @RequestMapping(method = RequestMethod.POST, value = "/save",
17 | produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
18 | @ResponseBody List save(@RequestBody String name);
19 | }
20 |
--------------------------------------------------------------------------------
/ch12/ui/src/main/java/com/wisely/ui/service/SomeHystrixService.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ui.service;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.stereotype.Service;
5 | import org.springframework.web.client.RestTemplate;
6 |
7 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
8 |
9 | @Service
10 | public class SomeHystrixService {
11 |
12 | @Autowired
13 | RestTemplate restTemplate; //1
14 |
15 | @HystrixCommand(fallbackMethod = "fallbackSome") //2
16 | public String getSome() {
17 | return restTemplate.getForObject("http://some/getsome", String.class);
18 | }
19 |
20 | public String fallbackSome(){
21 | return "some service模块故障";
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ch12/ui/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8000
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ch12/ui/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: ui
4 |
5 | eureka:
6 | instance:
7 | non-secure-port: ${server.port:80}
8 | client:
9 | service-url:
10 | defaultZone: http://${eureka.host:localhost}:${eureka.port:8761}/eureka/
--------------------------------------------------------------------------------
/ch12/ui/src/main/resources/static/css/application.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding-top: 60px;
3 | }
4 |
5 | h1, h2, h3, h4, h5, h6 {
6 | font-family: microsoft yahei;
7 | }
8 | p, div {
9 | font-family: microsoft yahei;
10 | font-size: 12px;
11 | }
12 |
13 | .longtext {
14 | word-break:break-all;
15 | }
16 |
--------------------------------------------------------------------------------
/ch12/ui/src/main/resources/static/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/ui/src/main/resources/static/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/ch12/ui/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/ui/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/ch12/ui/src/main/resources/static/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/ui/src/main/resources/static/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/ch12/ui/src/main/resources/static/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 原生云应用
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
30 |
35 |
36 |
--------------------------------------------------------------------------------
/ch12/ui/src/main/resources/static/js/app.js:
--------------------------------------------------------------------------------
1 | var uiApp = angular.module("uiApp", ["ui.router"]);
2 |
3 | uiApp.config(function ($stateProvider, $urlRouterProvider) {
4 | $urlRouterProvider.otherwise("person");
5 |
6 | $stateProvider
7 | .state('person', {
8 | url: '/person',
9 | templateUrl: '/tpl/person.html',
10 | controller: 'PersonController'
11 | })
12 | .state('some',{
13 | url:'/some',
14 | templateUrl: '/tpl/some.html',
15 | controller: 'SomeController'
16 | });
17 | });
18 |
19 |
20 | uiApp.controller("PersonController", function ($scope, $http) {
21 |
22 | $scope.people = "";
23 | $scope.errorMessage = "";
24 |
25 | $scope.getMessageResponse = function(personName) {
26 | $http.post('/dispatch', personName).success(function(data){
27 | $scope.people = data;
28 | $scope.errorMessage = "";
29 | }).error(function() {
30 | $scope.errorMessage = "错误";
31 | });
32 | }
33 |
34 | });
35 |
36 |
37 | uiApp.controller("SomeController", function ($scope, $http) {
38 | $scope.str = "";
39 | $scope.errorMessage = "";
40 |
41 | $scope.getSome = function(){
42 | $http.get('/getsome').success(function(data){
43 | $scope.str = data;
44 | $scope.errorMessage = "";
45 | }).error(function() {
46 | $scope.errorMessage = "错误";
47 | });
48 | }
49 | });
--------------------------------------------------------------------------------
/ch12/ui/src/main/resources/static/tpl/person.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
通过Person Service保存person
6 |
7 |
8 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/ch12/ui/src/main/resources/static/tpl/some.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
从 Some Service获得字符
6 |
7 |
8 |
9 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/ch12/ui/target/classes/com/wisely/ui/UiApplication.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/ui/target/classes/com/wisely/ui/UiApplication.class
--------------------------------------------------------------------------------
/ch12/ui/target/classes/com/wisely/ui/controller/UiController.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/ui/target/classes/com/wisely/ui/controller/UiController.class
--------------------------------------------------------------------------------
/ch12/ui/target/classes/com/wisely/ui/domain/Person.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/ui/target/classes/com/wisely/ui/domain/Person.class
--------------------------------------------------------------------------------
/ch12/ui/target/classes/com/wisely/ui/service/PersonHystrixService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/ui/target/classes/com/wisely/ui/service/PersonHystrixService.class
--------------------------------------------------------------------------------
/ch12/ui/target/classes/com/wisely/ui/service/PersonService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/ui/target/classes/com/wisely/ui/service/PersonService.class
--------------------------------------------------------------------------------
/ch12/ui/target/classes/com/wisely/ui/service/SomeHystrixService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/ui/target/classes/com/wisely/ui/service/SomeHystrixService.class
--------------------------------------------------------------------------------
/ch12/ui/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst:
--------------------------------------------------------------------------------
1 | com/wisely/ui/service/PersonService.class
2 | com/wisely/ui/service/PersonHystrixService.class
3 | com/wisely/ui/UiApplication.class
4 | com/wisely/ui/service/SomeHystrixService.class
5 | com/wisely/ui/controller/UiController.class
6 | com/wisely/ui/domain/Person.class
7 |
--------------------------------------------------------------------------------
/ch12/ui/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst:
--------------------------------------------------------------------------------
1 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/ui/src/main/java/com/wisely/ui/service/PersonHystrixService.java
2 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/ui/src/main/java/com/wisely/ui/domain/Person.java
3 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/ui/src/main/java/com/wisely/ui/service/SomeHystrixService.java
4 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/ui/src/main/java/com/wisely/ui/service/PersonService.java
5 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/ui/src/main/java/com/wisely/ui/controller/UiController.java
6 | /home/wxd/workspace/idea/springboot-SourceCode/ch12/ui/src/main/java/com/wisely/ui/UiApplication.java
7 |
--------------------------------------------------------------------------------
/ch12/ui/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch12/ui/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
--------------------------------------------------------------------------------
/ch5_2_2/src/main/java/com/wisely/ch5_2_2/Ch522Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch5_2_2;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | @RestController
10 | @SpringBootApplication
11 | public class Ch522Application {
12 |
13 | @Value("${book.author}")
14 | private String bookAuthor;
15 | @Value("${book.name}")
16 | private String bookName;
17 |
18 | @RequestMapping("/")
19 | String index() {
20 |
21 | return "book name is:"+bookName+" and book author is:" + bookAuthor;
22 | }
23 |
24 | public static void main(String[] args) {
25 | SpringApplication.run(Ch522Application.class, args);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ch5_2_2/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9090
2 | server.CONTEXT_PATH=/helloboot
3 |
4 | book.author=wangyunfei
5 | book.name=spring boot
6 |
7 | logging.file=D:/mylog/log.log
8 | logging.level.org.springframework.web: DEBUG
9 |
--------------------------------------------------------------------------------
/ch5_2_2/src/main/resources/application.xx:
--------------------------------------------------------------------------------
1 | server:
2 | port: 9090
3 | contextPath: /helloboot
--------------------------------------------------------------------------------
/ch5_2_2/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 | '##:::::'##:'####::'######::'########:'##:::::::'##:::'##:
2 | ##:'##: ##:. ##::'##... ##: ##.....:: ##:::::::. ##:'##::
3 | ##: ##: ##:: ##:: ##:::..:: ##::::::: ##::::::::. ####:::
4 | ##: ##: ##:: ##::. ######:: ######::: ##:::::::::. ##::::
5 | ##: ##: ##:: ##:::..... ##: ##...:::: ##:::::::::: ##::::
6 | ##: ##: ##:: ##::'##::: ##: ##::::::: ##:::::::::: ##::::
7 | . ###. ###::'####:. ######:: ########: ########:::: ##::::
8 | :...::...:::....:::......:::........::........:::::..:::::
--------------------------------------------------------------------------------
/ch5_2_2/src/test/java/com/wisely/ch5_2_2/Ch522ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch5_2_2;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch522Application.class)
11 | @WebAppConfiguration
12 | public class Ch522ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch5_2_3/src/main/java/com/wisely/ch5_2_3/Ch523Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch5_2_3;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.stereotype.Controller;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 |
8 | @Controller
9 | @SpringBootApplication
10 | public class Ch523Application {
11 |
12 | public static void main(String[] args) {
13 | SpringApplication.run(Ch523Application.class, args);
14 | }
15 |
16 | @RequestMapping("/")
17 | String home() {
18 | return "Hello Spring Boot!";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ch5_2_3/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch5_2_3/src/main/resources/application.properties
--------------------------------------------------------------------------------
/ch5_2_3/src/test/java/com/wisely/ch5_2_3/Ch523ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch5_2_3;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch523Application.class)
11 | @WebAppConfiguration
12 | public class Ch523ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch6_2_3/src/main/java/com/wisely/ch6_2_3/Ch623Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch6_2_3;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | import com.wisely.ch6_2_3.config.AuthorSettings;
10 | @RestController
11 | @SpringBootApplication
12 | public class Ch623Application {
13 |
14 | @Autowired
15 | private AuthorSettings authorSettings; //1
16 |
17 | @RequestMapping("/")
18 | public String index(){
19 | return "author name is "+ authorSettings.getName()+" and author age is "+authorSettings.getAge();
20 | }
21 |
22 | public static void main(String[] args) {
23 | SpringApplication.run(Ch623Application.class, args);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ch6_2_3/src/main/java/com/wisely/ch6_2_3/config/AuthorSettings.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch6_2_3.config;
2 |
3 | import org.springframework.boot.context.properties.ConfigurationProperties;
4 | import org.springframework.stereotype.Component;
5 | @Component
6 | @ConfigurationProperties(prefix = "author") //1
7 | public class AuthorSettings {
8 | private String name;
9 | private Long age;
10 |
11 | public String getName() {
12 | return name;
13 | }
14 |
15 | public void setName(String name) {
16 | this.name = name;
17 | }
18 |
19 | public Long getAge() {
20 | return age;
21 | }
22 |
23 | public void setAge(Long age) {
24 | this.age = age;
25 | }
26 | }
--------------------------------------------------------------------------------
/ch6_2_3/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | author.name=wyf
2 | author.age=32
--------------------------------------------------------------------------------
/ch6_2_3/src/test/java/com/wisely/ch6_2_3/Ch623ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch6_2_3;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch623Application.class)
11 | @WebAppConfiguration
12 | public class Ch623ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch6_4/src/main/java/com/wisely/ch6_4/Ch64Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch6_4;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Ch64Application {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(Ch64Application.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch6_4/src/main/resources/application-dev.properties:
--------------------------------------------------------------------------------
1 | server.port=8888
--------------------------------------------------------------------------------
/ch6_4/src/main/resources/application-prod.properties:
--------------------------------------------------------------------------------
1 | server.port=80
2 | debug=true
--------------------------------------------------------------------------------
/ch6_4/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.profiles.active=prod
--------------------------------------------------------------------------------
/ch6_4/src/test/java/com/wisely/ch6_4/Ch64ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch6_4;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch64Application.class)
11 | @WebAppConfiguration
12 | public class Ch64ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch6_5/src/main/java/com/wisely/ch6_5/Ch65Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch6_5;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | import com.wisely.spring_boot_starter_hello.HelloService;
10 | @RestController
11 | @SpringBootApplication
12 | public class Ch65Application {
13 |
14 | @Autowired
15 | HelloService helloService;
16 |
17 | @RequestMapping("/")
18 | public String index(){
19 | return helloService.sayHello();
20 | }
21 |
22 | public static void main(String[] args) {
23 | SpringApplication.run(Ch65Application.class, args);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ch6_5/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | hello.msg= wangyunfei
2 | debug=true
--------------------------------------------------------------------------------
/ch6_5/src/test/java/com/wisely/ch6_5/Ch65ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch6_5;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch65Application.class)
11 | @WebAppConfiguration
12 | public class Ch65ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch7_2/src/main/java/com/wisely/Ch72Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import org.springframework.boot.SpringApplication;
7 | import org.springframework.boot.autoconfigure.SpringBootApplication;
8 | import org.springframework.stereotype.Controller;
9 | import org.springframework.ui.Model;
10 | import org.springframework.web.bind.annotation.RequestMapping;
11 | @Controller
12 | @SpringBootApplication
13 | public class Ch72Application {
14 |
15 | @RequestMapping("/")
16 | public String index(Model model){
17 | Person single = new Person("aa",11);
18 |
19 | List people = new ArrayList();
20 | Person p1 = new Person("xx",11);
21 | Person p2 = new Person("yy",22);
22 | Person p3 = new Person("zz",33);
23 | people.add(p1);
24 | people.add(p2);
25 | people.add(p3);
26 |
27 | model.addAttribute("singlePerson", single);
28 | model.addAttribute("people", people);
29 |
30 | return "index";
31 | }
32 |
33 | // @RequestMapping(value = "/json",produces={MediaType.APPLICATION_JSON_VALUE})
34 | // public String json(Model model) {
35 | // Person single = new Person("aa",11);
36 | // model.addAttribute("single", single);
37 | // return "jsonView";
38 | // }
39 | //
40 | // @Bean
41 | // public MappingJackson2JsonView jsonView(){
42 | // MappingJackson2JsonView jsonView = new MappingJackson2JsonView();
43 | // return jsonView;
44 | // }
45 |
46 | public static void main(String[] args) {
47 | SpringApplication.run(Ch72Application.class, args);
48 | }
49 |
50 |
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/ch7_2/src/main/java/com/wisely/Person.java:
--------------------------------------------------------------------------------
1 | package com.wisely;
2 |
3 | public class Person {
4 | private String name;
5 | private Integer age;
6 |
7 | public Person() {
8 | super();
9 | }
10 | public Person(String name, Integer age) {
11 | super();
12 | this.name = name;
13 | this.age = age;
14 | }
15 | public String getName() {
16 | return name;
17 | }
18 | public void setName(String name) {
19 | this.name = name;
20 | }
21 | public Integer getAge() {
22 | return age;
23 | }
24 | public void setAge(Integer age) {
25 | this.age = age;
26 | }
27 |
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/ch7_2/src/main/java/com/wisely/WebMvcConfig.java:
--------------------------------------------------------------------------------
1 | package com.wisely;
2 |
3 | import org.springframework.context.annotation.Configuration;
4 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
6 |
7 | @Configuration
8 | public class WebMvcConfig extends WebMvcConfigurerAdapter{
9 |
10 | @Override
11 | public void addViewControllers(ViewControllerRegistry registry) {
12 | registry.addViewController("/xx").setViewName("/xx");
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/ch7_2/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | logging.level.org.springframework.web = DEBUG
--------------------------------------------------------------------------------
/ch7_2/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_2/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/ch7_2/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_2/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/ch7_2/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_2/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/ch7_2/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_2/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/ch7_2/src/main/resources/static/bootstrap/js/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/ch7_2/src/test/java/com/wisely/Ch72ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch72Application.class)
11 | @WebAppConfiguration
12 | public class Ch72ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch7_4/.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_4/.keystore
--------------------------------------------------------------------------------
/ch7_4/src/main/java/com/wisely/ch7_4/CustomServletContainer.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch7_4;
2 |
3 | import java.util.concurrent.TimeUnit;
4 |
5 | import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
6 | import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
7 | import org.springframework.boot.context.embedded.ErrorPage;
8 | import org.springframework.http.HttpStatus;
9 | import org.springframework.stereotype.Component;
10 |
11 | @Component
12 | public class CustomServletContainer implements EmbeddedServletContainerCustomizer{
13 |
14 | @Override
15 | public void customize(ConfigurableEmbeddedServletContainer container) {
16 | container.setPort(8888);
17 | container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/404.html"));
18 | container.setSessionTimeout(10,TimeUnit.MINUTES);
19 |
20 | }
21 |
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/ch7_4/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #server.port = 8443
2 | #server.ssl.key-store = .keystore
3 | #server.ssl.key-store-password= 111111
4 | #server.ssl.keyStoreType= JKS
5 | #server.ssl.keyAlias: tomcat
6 | #
7 | #logging.level.org.springframework.web = DEBUG
8 |
9 | #spring.mvc.favicon.enabled=false
--------------------------------------------------------------------------------
/ch7_4/src/main/resources/static/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Insert title here
6 |
7 |
8 | page not found
9 |
10 |
--------------------------------------------------------------------------------
/ch7_4/src/main/resources/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_4/src/main/resources/static/favicon.ico
--------------------------------------------------------------------------------
/ch7_4/src/main/resources/static/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Insert title here
6 |
7 |
8 | index page
9 |
10 |
--------------------------------------------------------------------------------
/ch7_4/src/test/java/com/wisely/ch7_4/Ch74ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch7_4;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch74Application.class)
11 | @WebAppConfiguration
12 | public class Ch74ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch7_6/src/main/java/com/wisely/ch7_6/Ch76Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch7_6;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Ch76Application {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(Ch76Application.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch7_6/src/main/java/com/wisely/ch7_6/WebMvcConfig.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch7_6;
2 |
3 | import org.springframework.context.annotation.Configuration;
4 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
6 |
7 | @Configuration
8 | public class WebMvcConfig extends WebMvcConfigurerAdapter{
9 |
10 | @Override
11 | public void addViewControllers(ViewControllerRegistry registry) {
12 | registry.addViewController("/ws").setViewName("/ws");
13 | registry.addViewController("/login").setViewName("/login");
14 | registry.addViewController("/chat").setViewName("/chat");
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/ch7_6/src/main/java/com/wisely/ch7_6/WebSocketConfig.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch7_6;
2 |
3 | import org.springframework.context.annotation.Configuration;
4 | import org.springframework.messaging.simp.config.MessageBrokerRegistry;
5 | import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
6 | import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
7 | import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
8 |
9 | @Configuration
10 | @EnableWebSocketMessageBroker
11 | public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer{
12 |
13 | @Override
14 | public void registerStompEndpoints(StompEndpointRegistry registry) {
15 | registry.addEndpoint("/endpointWisely").withSockJS();
16 | registry.addEndpoint("/endpointChat").withSockJS();//1
17 | }
18 |
19 |
20 | @Override
21 | public void configureMessageBroker(MessageBrokerRegistry registry) {
22 | registry.enableSimpleBroker("/queue","/topic"); //2
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/ch7_6/src/main/java/com/wisely/ch7_6/domain/WiselyMessage.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch7_6.domain;
2 |
3 | public class WiselyMessage {
4 | private String name;
5 |
6 | public String getName(){
7 | return name;
8 | }
9 | }
--------------------------------------------------------------------------------
/ch7_6/src/main/java/com/wisely/ch7_6/domain/WiselyResponse.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch7_6.domain;
2 |
3 | public class WiselyResponse {
4 | private String responseMessage;
5 | public WiselyResponse(String responseMessage){
6 | this.responseMessage = responseMessage;
7 | }
8 | public String getResponseMessage(){
9 | return responseMessage;
10 | }
11 | }
--------------------------------------------------------------------------------
/ch7_6/src/main/java/com/wisely/ch7_6/web/WsController.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch7_6.web;
2 |
3 | import java.security.Principal;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.messaging.handler.annotation.MessageMapping;
7 | import org.springframework.messaging.handler.annotation.SendTo;
8 | import org.springframework.messaging.simp.SimpMessagingTemplate;
9 | import org.springframework.stereotype.Controller;
10 |
11 | import com.wisely.ch7_6.domain.WiselyMessage;
12 | import com.wisely.ch7_6.domain.WiselyResponse;
13 |
14 | @Controller
15 | public class WsController {
16 |
17 | @MessageMapping("/welcome")
18 | @SendTo("/topic/getResponse")
19 | public WiselyResponse say(WiselyMessage message) throws Exception {
20 | Thread.sleep(3000);
21 | return new WiselyResponse("Welcome, " + message.getName() + "!");
22 | }
23 |
24 | @Autowired
25 | private SimpMessagingTemplate messagingTemplate;//1
26 |
27 | @MessageMapping("/chat")
28 | public void handleChat(Principal principal, String msg) { //2
29 | if (principal.getName().equals("wyf")) {//3
30 | messagingTemplate.convertAndSendToUser("wisely",
31 | "/queue/notifications", principal.getName() + "-send:"
32 | + msg);
33 | } else {
34 | messagingTemplate.convertAndSendToUser("wyf",
35 | "/queue/notifications", principal.getName() + "-send:"
36 | + msg);
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/ch7_6/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_6/src/main/resources/application.properties
--------------------------------------------------------------------------------
/ch7_6/src/main/resources/templates/chat.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Home
7 |
8 |
9 |
10 |
11 |
12 |
13 | 聊天室
14 |
15 |
16 |
20 |
21 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/ch7_6/src/main/resources/templates/login.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 | 登陆页面
7 |
8 |
9 |
10 | 无效的账号和密码
11 |
12 |
13 | 你已注销
14 |
15 |
20 |
21 |
--------------------------------------------------------------------------------
/ch7_6/src/test/java/com/wisely/ch7_6/Ch76ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch7_6;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch76Application.class)
11 | @WebAppConfiguration
12 | public class Ch76ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch7_7/src/main/java/com/wisely/ch7_7/Ch77Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch7_7;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.http.MediaType;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | @RestController
10 | @SpringBootApplication
11 | public class Ch77Application {
12 |
13 | @RequestMapping(value="/search",produces={MediaType.APPLICATION_JSON_VALUE})
14 | public Person search(String personName){
15 |
16 | return new Person(personName, 32, "hefei");
17 |
18 | }
19 |
20 | public static void main(String[] args) {
21 | SpringApplication.run(Ch77Application.class, args);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ch7_7/src/main/java/com/wisely/ch7_7/Person.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch7_7;
2 |
3 | public class Person {
4 | private String name;
5 | private Integer age;
6 | private String address;
7 |
8 |
9 | public Person() {
10 | super();
11 | }
12 | public Person(String name, Integer age, String address) {
13 | super();
14 | this.name = name;
15 | this.age = age;
16 | this.address = address;
17 | }
18 | public String getName() {
19 | return name;
20 | }
21 | public void setName(String name) {
22 | this.name = name;
23 | }
24 | public Integer getAge() {
25 | return age;
26 | }
27 | public void setAge(Integer age) {
28 | this.age = age;
29 | }
30 | public String getAddress() {
31 | return address;
32 | }
33 | public void setAddress(String address) {
34 | this.address = address;
35 | }
36 |
37 |
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/application.properties
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/angularjs.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | 你好 {{yourName}}!
13 |
14 |
15 |
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/bootstrap/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/bootstrap/js/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_diagonals-thick_18_b81900_40x40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_diagonals-thick_18_b81900_40x40.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_diagonals-thick_20_666666_40x40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_diagonals-thick_20_666666_40x40.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_flat_10_000000_40x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_flat_10_000000_40x100.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_glass_100_f6f6f6_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_glass_100_f6f6f6_1x400.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_glass_100_fdf5ce_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_glass_100_fdf5ce_1x400.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_glass_65_ffffff_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_glass_65_ffffff_1x400.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_gloss-wave_35_f6a828_500x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_gloss-wave_35_f6a828_500x100.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_highlight-soft_100_eeeeee_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_highlight-soft_75_ffe45c_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-bg_highlight-soft_75_ffe45c_1x100.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-icons_222222_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-icons_222222_256x240.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-icons_228ef1_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-icons_228ef1_256x240.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-icons_ef8c08_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-icons_ef8c08_256x240.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-icons_ffd27a_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-icons_ffd27a_256x240.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/jqueryui/images/ui-icons_ffffff_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch7_7/src/main/resources/static/jqueryui/images/ui-icons_ffffff_256x240.png
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/js-action/app.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 |
5 | var actionApp = angular.module('actionApp',['ngRoute']);
6 |
7 |
8 |
9 |
10 | actionApp.config(['$routeProvider' , function($routeProvider) {
11 |
12 | $routeProvider.when('/oper', {
13 | controller: 'View1Controller',
14 | templateUrl: 'views/view1.html',
15 | }).when('/directive', {
16 | controller: 'View2Controller',
17 | templateUrl: 'views/view2.html',
18 | });
19 |
20 | }]);
21 |
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/js-action/controllers.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 |
5 | actionApp.controller('View1Controller', ['$rootScope', '$scope', '$http', function($rootScope, $scope,$http) {
6 | $scope.$on('$viewContentLoaded', function() {
7 | console.log('页面加载完成');
8 | });
9 |
10 |
11 | $scope.search = function(){
12 | personName = $scope.personName;
13 | $http.get('search',{
14 | params:{personName:personName}
15 | }).success(function(data){
16 | $scope.person=data;
17 | });;
18 |
19 | };
20 | }]);
21 |
22 | actionApp.controller('View2Controller', ['$rootScope', '$scope', function($rootScope, $scope) {
23 | $scope.$on('$viewContentLoaded', function() {
24 | console.log('页面加载完成');
25 | });
26 | }]);
27 |
28 |
29 |
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/js-action/directives.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 |
5 | actionApp.directive('datePicker',function(){
6 | return {
7 | restrict: 'AC',
8 | link:function(scope,elem,attrs){
9 | // scope.treeObj = $.fn.zTree.init(elem, scope.settings);
10 |
11 | elem.datepicker();
12 | }
13 | };
14 | });
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/js-action/services.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/views/view1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | - 名字: {{person.name}}
15 | - 年龄: {{person.age}}
16 | - 地址: {{person.address}}
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/ch7_7/src/main/resources/static/views/view2.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/ch7_7/src/test/java/com/wisely/ch7_7/Ch77ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch7_7;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch77Application.class)
11 | @WebAppConfiguration
12 | public class Ch77ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch8_2/src/main/java/com/wisely/Ch82Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
7 |
8 | import com.wisely.dao.PersonRepository;
9 | import com.wisely.support.CustomRepositoryFactoryBean;
10 |
11 | @SpringBootApplication
12 | @EnableJpaRepositories(repositoryFactoryBeanClass = CustomRepositoryFactoryBean.class)
13 | public class Ch82Application {
14 | @Autowired
15 | PersonRepository personRepository;
16 |
17 |
18 | public static void main(String[] args) {
19 | SpringApplication.run(Ch82Application.class, args);
20 |
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/ch8_2/src/main/java/com/wisely/dao/PersonRepository.java:
--------------------------------------------------------------------------------
1 | package com.wisely.dao;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.data.jpa.repository.Query;
6 | import org.springframework.data.repository.query.Param;
7 |
8 | import com.wisely.domain.Person;
9 | import com.wisely.support.CustomRepository;
10 |
11 | public interface PersonRepository extends CustomRepository {
12 | List findByAddress(String address);
13 |
14 | Person findByNameAndAddress(String name,String address);
15 |
16 | @Query("select p from Person p where p.name= :name and p.address= :address")
17 |
18 | Person withNameAndAddressQuery(@Param("name")String name,@Param("address")String address);
19 |
20 | Person withNameAndAddressNamedQuery(String name,String address);
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/ch8_2/src/main/java/com/wisely/domain/Person.java:
--------------------------------------------------------------------------------
1 | package com.wisely.domain;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 | import javax.persistence.NamedQuery;
7 |
8 | @Entity //1
9 | @NamedQuery(name = "Person.withNameAndAddressNamedQuery",
10 | query = "select p from Person p where p.name=?1 and address=?2")
11 | public class Person {
12 | @Id //2
13 | @GeneratedValue //3
14 | private Long id;
15 |
16 | private String name;
17 |
18 | private Integer age;
19 |
20 | private String address;
21 |
22 |
23 |
24 | public Person() {
25 | super();
26 | }
27 | public Person(Long id, String name, Integer age, String address) {
28 | super();
29 | this.id = id;
30 | this.name = name;
31 | this.age = age;
32 | this.address = address;
33 | }
34 | public Long getId() {
35 | return id;
36 | }
37 | public void setId(Long id) {
38 | this.id = id;
39 | }
40 | public String getName() {
41 | return name;
42 | }
43 | public void setName(String name) {
44 | this.name = name;
45 | }
46 | public Integer getAge() {
47 | return age;
48 | }
49 | public void setAge(Integer age) {
50 | this.age = age;
51 | }
52 | public String getAddress() {
53 | return address;
54 | }
55 | public void setAddress(String address) {
56 | this.address = address;
57 | }
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/ch8_2/src/main/java/com/wisely/support/CustomRepository.java:
--------------------------------------------------------------------------------
1 | package com.wisely.support;
2 |
3 | import java.io.Serializable;
4 |
5 | import org.springframework.data.domain.Page;
6 | import org.springframework.data.domain.Pageable;
7 | import org.springframework.data.jpa.repository.JpaRepository;
8 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
9 | import org.springframework.data.repository.NoRepositoryBean;
10 |
11 | @NoRepositoryBean
12 | public interface CustomRepositoryextends JpaRepository ,JpaSpecificationExecutor{
13 |
14 | Page findByAuto(T example,Pageable pageable);
15 |
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/ch8_2/src/main/java/com/wisely/support/CustomRepositoryImpl.java:
--------------------------------------------------------------------------------
1 | package com.wisely.support;
2 |
3 | import java.io.Serializable;
4 |
5 | import javax.persistence.EntityManager;
6 |
7 | import org.springframework.data.domain.Page;
8 | import org.springframework.data.domain.Pageable;
9 | import org.springframework.data.jpa.repository.support.SimpleJpaRepository;
10 |
11 | import static com.wisely.specs.CustomerSpecs.*;
12 |
13 | public class CustomRepositoryImpl
14 | extends SimpleJpaRepository implements CustomRepository {
15 |
16 | private final EntityManager entityManager;
17 |
18 | public CustomRepositoryImpl(Class domainClass, EntityManager entityManager) {
19 | super(domainClass, entityManager);
20 | this.entityManager = entityManager;
21 | }
22 |
23 | @Override
24 | public Page findByAuto(T example, Pageable pageable) {
25 | return findAll(byAuto(entityManager, example),pageable);
26 | }
27 |
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/ch8_2/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.driverClassName=oracle.jdbc.OracleDriver
2 | spring.datasource.url=jdbc\:oracle\:thin\:@localhost\:1521\:xe
3 | spring.datasource.username=boot
4 | spring.datasource.password=boot
5 |
6 | #1
7 | spring.jpa.hibernate.ddl-auto=update
8 | #2
9 | spring.jpa.show-sql=true
10 |
11 |
12 | spring.jackson.serialization.indent_output=true
--------------------------------------------------------------------------------
/ch8_2/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | insert into person(id,name,age,address) values(hibernate_sequence.nextval,'汪云飞',32,'合肥');
2 | insert into person(id,name,age,address) values(hibernate_sequence.nextval,'xx',31,'北京');
3 | insert into person(id,name,age,address) values(hibernate_sequence.nextval,'yy',30,'上海');
4 | insert into person(id,name,age,address) values(hibernate_sequence.nextval,'zz',29,'南京');
5 | insert into person(id,name,age,address) values(hibernate_sequence.nextval,'aa',28,'武汉');
6 | insert into person(id,name,age,address) values(hibernate_sequence.nextval,'bb',27,'合肥');
--------------------------------------------------------------------------------
/ch8_2/src/test/java/com/wisely/Ch82ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch82Application.class)
11 | @WebAppConfiguration
12 | public class Ch82ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch8_3/src/main/java/com/wisely/ch8_3/Ch83Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_3;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Ch83Application {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(Ch83Application.class, args);
11 | }
12 |
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/ch8_3/src/main/java/com/wisely/ch8_3/dao/PersonRepository.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_3.dao;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 | import org.springframework.data.repository.query.Param;
5 | import org.springframework.data.rest.core.annotation.RepositoryRestResource;
6 | import org.springframework.data.rest.core.annotation.RestResource;
7 |
8 | import com.wisely.ch8_3.domain.Person;
9 |
10 | @RepositoryRestResource(path = "people")
11 | public interface PersonRepository extends JpaRepository {
12 |
13 | @RestResource(path = "nameStartsWith", rel = "nameStartsWith")
14 | Person findByNameStartsWith(@Param("name")String name);
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/ch8_3/src/main/java/com/wisely/ch8_3/domain/Person.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_3.domain;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Person {
9 | @Id
10 | @GeneratedValue
11 | private Long id;
12 |
13 | private String name;
14 |
15 | private Integer age;
16 |
17 | private String address;
18 |
19 |
20 |
21 | public Person() {
22 | super();
23 | }
24 | public Person(Long id, String name, Integer age, String address) {
25 | super();
26 | this.id = id;
27 | this.name = name;
28 | this.age = age;
29 | this.address = address;
30 | }
31 | public Long getId() {
32 | return id;
33 | }
34 | public void setId(Long id) {
35 | this.id = id;
36 | }
37 | public String getName() {
38 | return name;
39 | }
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | public Integer getAge() {
44 | return age;
45 | }
46 | public void setAge(Integer age) {
47 | this.age = age;
48 | }
49 | public String getAddress() {
50 | return address;
51 | }
52 | public void setAddress(String address) {
53 | this.address = address;
54 | }
55 |
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/ch8_3/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.driverClassName=oracle.jdbc.OracleDriver
2 | spring.datasource.url=jdbc\:oracle\:thin\:@localhost\:1521\:xe
3 | spring.datasource.username=boot
4 | spring.datasource.password=boot
5 |
6 | #1
7 | spring.jpa.hibernate.ddl-auto=update
8 | #2
9 | spring.jpa.show-sql=true
10 |
11 |
12 | spring.jackson.serialization.indent_output=true
13 |
14 | spring.data.rest.base-path= /api
15 |
16 | debug=true
--------------------------------------------------------------------------------
/ch8_3/src/main/resources/data--.sql:
--------------------------------------------------------------------------------
1 | insert into person(id,name,age,address) values(hibernate_sequence.nextval,'汪云飞',32,'合肥');
2 | insert into person(id,name,age,address) values(hibernate_sequence.nextval,'xx',31,'北京');
3 | insert into person(id,name,age,address) values(hibernate_sequence.nextval,'yy',30,'上海');
4 | insert into person(id,name,age,address) values(hibernate_sequence.nextval,'zz',29,'南京');
5 | insert into person(id,name,age,address) values(hibernate_sequence.nextval,'aa',28,'武汉');
6 | insert into person(id,name,age,address) values(hibernate_sequence.nextval,'bb',27,'合肥');
--------------------------------------------------------------------------------
/ch8_3/src/main/resources/postman.crx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch8_3/src/main/resources/postman.crx
--------------------------------------------------------------------------------
/ch8_3/src/test/java/com/wisely/ch8_3/Ch83ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_3;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = Ch83Application.class)
10 | public class Ch83ApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/ch8_4/src/main/java/com/wisely/ch8_4/Ch84Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_4;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Ch84Application {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(Ch84Application.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch8_4/src/main/java/com/wisely/ch8_4/dao/PersonRepository.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_4.dao;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | import com.wisely.ch8_4.domain.Person;
6 |
7 | public interface PersonRepository extends JpaRepository {
8 |
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/ch8_4/src/main/java/com/wisely/ch8_4/domain/Person.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_4.domain;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Person {
9 | @Id
10 | @GeneratedValue
11 | private Long id;
12 |
13 | private String name;
14 |
15 | private Integer age;
16 |
17 | private String address;
18 |
19 |
20 | public Person() {
21 | super();
22 | }
23 | public Person(Long id, String name, Integer age, String address) {
24 | super();
25 | this.id = id;
26 | this.name = name;
27 | this.age = age;
28 | this.address = address;
29 | }
30 | public Long getId() {
31 | return id;
32 | }
33 | public void setId(Long id) {
34 | this.id = id;
35 | }
36 | public String getName() {
37 | return name;
38 | }
39 | public void setName(String name) {
40 | this.name = name;
41 | }
42 | public Integer getAge() {
43 | return age;
44 | }
45 | public void setAge(Integer age) {
46 | this.age = age;
47 | }
48 | public String getAddress() {
49 | return address;
50 | }
51 | public void setAddress(String address) {
52 | this.address = address;
53 | }
54 |
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/ch8_4/src/main/java/com/wisely/ch8_4/service/DemoService.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_4.service;
2 |
3 | import com.wisely.ch8_4.domain.Person;
4 |
5 | public interface DemoService {
6 | public Person savePersonWithRollBack(Person person);
7 | public Person savePersonWithoutRollBack(Person person);
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/ch8_4/src/main/java/com/wisely/ch8_4/service/impl/DemoServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_4.service.impl;
2 |
3 |
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.stereotype.Service;
6 | import org.springframework.transaction.annotation.Transactional;
7 |
8 | import com.wisely.ch8_4.dao.PersonRepository;
9 | import com.wisely.ch8_4.domain.Person;
10 | import com.wisely.ch8_4.service.DemoService;
11 | @Service
12 | public class DemoServiceImpl implements DemoService {
13 | @Autowired
14 | PersonRepository personRepository; //1
15 |
16 | @Transactional(rollbackFor={IllegalArgumentException.class}) //2
17 | public Person savePersonWithRollBack(Person person){
18 | Person p =personRepository.save(person);
19 |
20 | if(person.getName().equals("汪云飞")){
21 | throw new IllegalArgumentException("汪云飞已存在,数据将回滚"); //3
22 | }
23 | return p;
24 | }
25 |
26 | @Transactional(noRollbackFor={IllegalArgumentException.class}) //4
27 | public Person savePersonWithoutRollBack(Person person){
28 | Person p =personRepository.save(person);
29 |
30 | if(person.getName().equals("汪云飞")){
31 | throw new IllegalArgumentException("汪云飞虽已存在,数据将不会回滚");
32 | }
33 | return p;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/ch8_4/src/main/java/com/wisely/ch8_4/web/MyController.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_4.web;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 | import org.springframework.web.bind.annotation.RestController;
6 |
7 | import com.wisely.ch8_4.domain.Person;
8 | import com.wisely.ch8_4.service.DemoService;
9 |
10 | @RestController
11 | public class MyController {
12 | @Autowired
13 | DemoService demoService;
14 |
15 | @RequestMapping("/rollback")
16 | public Person rollback(Person person){ //1
17 |
18 | return demoService.savePersonWithRollBack(person);
19 | }
20 |
21 | @RequestMapping("/norollback")
22 | public Person noRollback(Person person){//2
23 |
24 | return demoService.savePersonWithoutRollBack(person);
25 |
26 |
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/ch8_4/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.driverClassName=oracle.jdbc.OracleDriver
2 | spring.datasource.url=jdbc\:oracle\:thin\:@localhost\:1521\:xe
3 | spring.datasource.username=boot
4 | spring.datasource.password=boot
5 |
6 | #1
7 | spring.jpa.hibernate.ddl-auto=update
8 | #2
9 | spring.jpa.show-sql=true
10 |
11 |
12 | spring.jackson.serialization.indent_output=true
--------------------------------------------------------------------------------
/ch8_4/src/test/java/com/wisely/ch8_4/Ch84ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_4;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch84Application.class)
11 | @WebAppConfiguration
12 | public class Ch84ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch8_5/src/main/java/com/wisely/ch8_5/AppConfig.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_5;
2 |
3 | import org.springframework.cache.annotation.EnableCaching;
4 | import org.springframework.context.annotation.Configuration;
5 |
6 | @Configuration
7 | @EnableCaching
8 | public class AppConfig {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/ch8_5/src/main/java/com/wisely/ch8_5/Ch85Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_5;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cache.annotation.EnableCaching;
6 |
7 | @SpringBootApplication
8 | @EnableCaching
9 | public class Ch85Application {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(Ch85Application.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch8_5/src/main/java/com/wisely/ch8_5/dao/PersonRepository.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_5.dao;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | import com.wisely.ch8_5.domain.Person;
6 |
7 | public interface PersonRepository extends JpaRepository {
8 |
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/ch8_5/src/main/java/com/wisely/ch8_5/domain/Person.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_5.domain;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Person {
9 | @Id
10 | @GeneratedValue
11 | private Long id;
12 |
13 | private String name;
14 |
15 | private Integer age;
16 |
17 | private String address;
18 |
19 |
20 | public Person() {
21 | super();
22 | }
23 | public Person(Long id, String name, Integer age, String address) {
24 | super();
25 | this.id = id;
26 | this.name = name;
27 | this.age = age;
28 | this.address = address;
29 | }
30 | public Long getId() {
31 | return id;
32 | }
33 | public void setId(Long id) {
34 | this.id = id;
35 | }
36 | public String getName() {
37 | return name;
38 | }
39 | public void setName(String name) {
40 | this.name = name;
41 | }
42 | public Integer getAge() {
43 | return age;
44 | }
45 | public void setAge(Integer age) {
46 | this.age = age;
47 | }
48 | public String getAddress() {
49 | return address;
50 | }
51 | public void setAddress(String address) {
52 | this.address = address;
53 | }
54 |
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/ch8_5/src/main/java/com/wisely/ch8_5/service/DemoService.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_5.service;
2 |
3 | import com.wisely.ch8_5.domain.Person;
4 |
5 | public interface DemoService {
6 | public Person save(Person person);
7 |
8 | public void remove(Long id);
9 |
10 | public Person findOne(Person person);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/ch8_5/src/main/java/com/wisely/ch8_5/service/impl/DemoServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_5.service.impl;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.cache.annotation.CacheEvict;
5 | import org.springframework.cache.annotation.CachePut;
6 | import org.springframework.cache.annotation.Cacheable;
7 | import org.springframework.stereotype.Service;
8 |
9 | import com.wisely.ch8_5.dao.PersonRepository;
10 | import com.wisely.ch8_5.domain.Person;
11 | import com.wisely.ch8_5.service.DemoService;
12 |
13 |
14 | @Service
15 | public class DemoServiceImpl implements DemoService {
16 |
17 | @Autowired
18 | PersonRepository personRepository;
19 |
20 | @Override
21 | @CachePut(value = "people", key = "#person.id")
22 | public Person save(Person person) {
23 | Person p = personRepository.save(person);
24 | System.out.println("为id、key为:"+p.getId()+"数据做了缓存");
25 | return p;
26 | }
27 |
28 | @Override
29 | @CacheEvict(value = "people")//2
30 | public void remove(Long id) {
31 | System.out.println("删除了id、key为"+id+"的数据缓存");
32 | //这里不做实际删除操作
33 | }
34 |
35 | @Override
36 | @Cacheable(value = "people", key = "#person.id")//3
37 | public Person findOne(Person person) {
38 | Person p = personRepository.findOne(person.getId());
39 | System.out.println("为id、key为:"+p.getId()+"数据做了缓存");
40 | return p;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/ch8_5/src/main/java/com/wisely/ch8_5/web/CacheController.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_5.web;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 | import org.springframework.web.bind.annotation.RestController;
6 |
7 | import com.wisely.ch8_5.domain.Person;
8 | import com.wisely.ch8_5.service.DemoService;
9 |
10 | @RestController
11 | public class CacheController {
12 |
13 | @Autowired
14 | DemoService demoService;
15 |
16 |
17 |
18 |
19 | @RequestMapping("/put")
20 | public Person put(Person person){
21 | return demoService.save(person);
22 |
23 | }
24 |
25 |
26 | @RequestMapping("/able")
27 | public Person cacheable(Person person){
28 |
29 |
30 | return demoService.findOne(person);
31 |
32 | }
33 |
34 | @RequestMapping("/evit")
35 | public String evit(Long id){
36 | demoService.remove(id);
37 | return "ok";
38 |
39 | }
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/ch8_5/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.driverClassName=oracle.jdbc.OracleDriver
2 | spring.datasource.url=jdbc\:oracle\:thin\:@localhost\:1521\:xe
3 | spring.datasource.username=boot
4 | spring.datasource.password=boot
5 |
6 | spring.jpa.hibernate.ddl-auto=update
7 | spring.jpa.show-sql=true
8 |
9 |
10 | spring.jackson.serialization.indent_output=true
--------------------------------------------------------------------------------
/ch8_5/src/main/resources/ehcache.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ch8_5/src/test/java/com/wisely/ch8_5/Ch85ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_5;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch85Application.class)
11 | @WebAppConfiguration
12 | public class Ch85ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch8_6_1/src/main/java/com/wisely/ch8_6_1/Ch861Application.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_6_1;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Ch861Application {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(Ch861Application.class, args);
11 | }
12 |
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/ch8_6_1/src/main/java/com/wisely/ch8_6_1/dao/PersonRepository.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_6_1.dao;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.data.mongodb.repository.MongoRepository;
6 | import org.springframework.data.mongodb.repository.Query;
7 |
8 | import com.wisely.ch8_6_1.domain.Person;
9 |
10 | public interface PersonRepository extends MongoRepository {
11 |
12 | Person findByName(String name);
13 |
14 | @Query("{'age': ?0}")
15 | List withQueryFindByAge(Integer age);
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/ch8_6_1/src/main/java/com/wisely/ch8_6_1/domain/Location.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_6_1.domain;
2 |
3 | public class Location {
4 |
5 | private String place;
6 |
7 | private String year;
8 |
9 |
10 |
11 | public Location(String place, String year) {
12 | super();
13 | this.place = place;
14 | this.year = year;
15 | }
16 |
17 | public String getPlace() {
18 | return place;
19 | }
20 |
21 | public void setPlace(String place) {
22 | this.place = place;
23 | }
24 |
25 | public String getYear() {
26 | return year;
27 | }
28 |
29 | public void setYear(String year) {
30 | this.year = year;
31 | }
32 |
33 |
34 |
35 |
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/ch8_6_1/src/main/java/com/wisely/ch8_6_1/domain/Person.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_6_1.domain;
2 |
3 | import java.util.Collection;
4 | import java.util.LinkedHashSet;
5 |
6 | import org.springframework.data.annotation.Id;
7 | import org.springframework.data.mongodb.core.mapping.Document;
8 | import org.springframework.data.mongodb.core.mapping.Field;
9 |
10 | @Document //1
11 | public class Person {
12 | @Id
13 | private String id;
14 | private String name;
15 | private Integer age;
16 | @Field("locs")
17 | private Collection locations = new LinkedHashSet();
18 |
19 |
20 | public Person(String name, Integer age) {
21 | super();
22 | this.name = name;
23 | this.age = age;
24 | }
25 |
26 | public String getId() {
27 | return id;
28 | }
29 |
30 | public void setId(String id) {
31 | this.id = id;
32 | }
33 |
34 | public String getName() {
35 | return name;
36 | }
37 |
38 | public void setName(String name) {
39 | this.name = name;
40 | }
41 |
42 | public Integer getAge() {
43 | return age;
44 | }
45 |
46 | public void setAge(Integer age) {
47 | this.age = age;
48 | }
49 |
50 | public Collection getLocations() {
51 | return locations;
52 | }
53 |
54 | public void setLocations(Collection locations) {
55 | this.locations = locations;
56 | }
57 |
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/ch8_6_1/src/main/java/com/wisely/ch8_6_1/web/DataController.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_6_1.web;
2 |
3 | import java.util.Collection;
4 | import java.util.LinkedHashSet;
5 | import java.util.List;
6 |
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | import com.wisely.ch8_6_1.dao.PersonRepository;
12 | import com.wisely.ch8_6_1.domain.Location;
13 | import com.wisely.ch8_6_1.domain.Person;
14 |
15 | @RestController
16 | public class DataController {
17 |
18 | @Autowired
19 | PersonRepository personRepository;
20 |
21 | @RequestMapping("/save")
22 | public Person save(){
23 | Person p = new Person("wyf",32);
24 | Collection locations = new LinkedHashSet();
25 | Location loc1 = new Location("上海","2009");
26 | Location loc2 = new Location("合肥","2010");
27 | Location loc3 = new Location("广州","2011");
28 | Location loc4 = new Location("马鞍山","2012");
29 | locations.add(loc1);
30 | locations.add(loc2);
31 | locations.add(loc3);
32 | locations.add(loc4);
33 | p.setLocations(locations);
34 |
35 | return personRepository.save(p);
36 | }
37 |
38 | @RequestMapping("/q1")
39 | public Person q1(String name){
40 | return personRepository.findByName(name);
41 | }
42 |
43 | @RequestMapping("/q2")
44 | public List q2(Integer age){
45 | return personRepository.withQueryFindByAge(age);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/ch8_6_1/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangxiaodong0120/springboot-wyf-sourcecode/777a264ccc01f2cd76dd4adc4db6914bf9c0266b/ch8_6_1/src/main/resources/application.properties
--------------------------------------------------------------------------------
/ch8_6_1/src/test/java/com/wisely/ch8_6_1/Ch861ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_6_1;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.test.context.web.WebAppConfiguration;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 |
9 | @RunWith(SpringJUnit4ClassRunner.class)
10 | @SpringApplicationConfiguration(classes = Ch861Application.class)
11 | @WebAppConfiguration
12 | public class Ch861ApplicationTests {
13 |
14 | @Test
15 | public void contextLoads() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ch8_6_2/src/main/java/com/wisely/ch8_6_2/dao/Person.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_6_2.dao;
2 |
3 | import java.io.Serializable;
4 |
5 | public class Person implements Serializable{
6 |
7 | private static final long serialVersionUID = 1L;
8 |
9 | private String id;
10 | private String name;
11 | private Integer age;
12 |
13 | public Person() {
14 | super();
15 | }
16 | public Person(String id,String name, Integer age) {
17 | super();
18 | this.id = id;
19 | this.name = name;
20 | this.age = age;
21 | }
22 | public String getId() {
23 | return id;
24 | }
25 | public void setId(String id) {
26 | this.id = id;
27 | }
28 | public String getName() {
29 | return name;
30 | }
31 | public void setName(String name) {
32 | this.name = name;
33 | }
34 | public Integer getAge() {
35 | return age;
36 | }
37 | public void setAge(Integer age) {
38 | this.age = age;
39 | }
40 |
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/ch8_6_2/src/main/java/com/wisely/ch8_6_2/domain/PersonDao.java:
--------------------------------------------------------------------------------
1 | package com.wisely.ch8_6_2.domain;
2 |
3 | import javax.annotation.Resource;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.data.redis.core.RedisTemplate;
7 | import org.springframework.data.redis.core.StringRedisTemplate;
8 | import org.springframework.data.redis.core.ValueOperations;
9 | import org.springframework.stereotype.Repository;
10 |
11 | import com.wisely.ch8_6_2.dao.Person;
12 |
13 | @Repository
14 | public class PersonDao {
15 |
16 | @Autowired
17 | StringRedisTemplate stringRedisTemplate; //1
18 |
19 | @Resource(name="stringRedisTemplate")
20 | ValueOperations valOpsStr; //3
21 |
22 |
23 | @Autowired
24 | RedisTemplate