├── .gitignore
├── README.md
├── VueDemo
├── hello-vue
│ ├── .babelrc
│ ├── .editorconfig
│ ├── .eslintignore
│ ├── .eslintrc.js
│ ├── .gitignore
│ ├── .postcssrc.js
│ ├── README.md
│ ├── build
│ │ ├── build.js
│ │ ├── check-versions.js
│ │ ├── logo.png
│ │ ├── utils.js
│ │ ├── vue-loader.conf.js
│ │ ├── webpack.base.conf.js
│ │ ├── webpack.dev.conf.js
│ │ └── webpack.prod.conf.js
│ ├── config
│ │ ├── dev.env.js
│ │ ├── index.js
│ │ ├── prod.env.js
│ │ └── test.env.js
│ ├── index.html
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── App.vue
│ │ ├── assets
│ │ │ ├── image
│ │ │ │ └── apple.png
│ │ │ └── logo.png
│ │ ├── components
│ │ │ ├── About.vue
│ │ │ ├── HelloWorld.vue
│ │ │ ├── css
│ │ │ │ ├── qui-btn.import.css
│ │ │ │ ├── qui-nav.import.css
│ │ │ │ └── reset.import.css
│ │ │ ├── quiArrow.vue
│ │ │ ├── quiButton.vue
│ │ │ ├── quiList.vue
│ │ │ └── quiNav.vue
│ │ ├── main.js
│ │ ├── pages
│ │ │ ├── css
│ │ │ │ ├── index.css
│ │ │ │ └── reset.import.css
│ │ │ ├── index.vue
│ │ │ ├── pageQuiButton.vue
│ │ │ └── pageQuiList.vue
│ │ └── router
│ │ │ └── index.js
│ ├── static
│ │ └── .gitkeep
│ └── test
│ │ ├── e2e
│ │ ├── custom-assertions
│ │ │ └── elementCount.js
│ │ ├── nightwatch.conf.js
│ │ ├── runner.js
│ │ └── specs
│ │ │ └── test.js
│ │ └── unit
│ │ ├── .eslintrc
│ │ ├── jest.conf.js
│ │ ├── setup.js
│ │ └── specs
│ │ └── HelloWorld.spec.js
├── index.html
└── springboot-vue
│ ├── .babelrc
│ ├── .editorconfig
│ ├── .gitignore
│ ├── .postcssrc.js
│ ├── README.md
│ ├── build
│ ├── build.js
│ ├── check-versions.js
│ ├── logo.png
│ ├── utils.js
│ ├── vue-loader.conf.js
│ ├── webpack.base.conf.js
│ ├── webpack.dev.conf.js
│ └── webpack.prod.conf.js
│ ├── config
│ ├── dev.env.js
│ ├── index.js
│ └── prod.env.js
│ ├── index.html
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ ├── App.vue
│ ├── assets
│ │ ├── LOGO.jpg
│ │ └── logo.png
│ ├── components
│ │ ├── HelloWorld.vue
│ │ ├── Home.vue
│ │ ├── User2.vue
│ │ ├── article
│ │ │ ├── ActicleEditor.vue
│ │ │ └── UserArticles.vue
│ │ ├── common
│ │ │ ├── Footer.vue
│ │ │ ├── NavMenu.vue
│ │ │ └── about.vue
│ │ ├── home
│ │ │ └── Index.vue
│ │ └── user
│ │ │ ├── HeaderUser.vue
│ │ │ ├── UserInfo.vue
│ │ │ ├── UserNav.vue
│ │ │ └── UserProfile.vue
│ ├── main.js
│ └── router
│ │ └── index.js
│ └── static
│ └── .gitkeep
├── pom.xml
├── spring-boot-ajax
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── ikeguang
│ │ └── ajax
│ │ ├── Application.java
│ │ ├── config
│ │ └── MysqlConfig.java
│ │ ├── dao
│ │ └── ExecutionJobsMapper.java
│ │ ├── model
│ │ ├── ExecutionJobs.java
│ │ └── SelectDate.java
│ │ └── web
│ │ └── AzkabanController.java
│ └── resources
│ ├── application.properties
│ ├── logback.xml
│ ├── mybatis
│ ├── mapper
│ │ └── AzkabanJobsMapper.xml
│ └── mybatis-config.xml
│ ├── static
│ ├── css
│ │ ├── bootstrap-datepicker.min.css
│ │ ├── bootstrap-datetimepicker.min.css
│ │ └── bootstrap.css
│ ├── fonts
│ │ ├── glyphicons-halflings-regular.eot
│ │ ├── glyphicons-halflings-regular.svg
│ │ ├── glyphicons-halflings-regular.ttf
│ │ ├── glyphicons-halflings-regular.woff
│ │ └── glyphicons-halflings-regular.woff2
│ ├── jquery
│ │ └── jquery-3.3.1.min.js
│ └── js
│ │ ├── bootstrap-datepicker.zh-CN.min.js
│ │ ├── bootstrap-datetimepicker.min.js
│ │ ├── bootstrap-datetimepicker.zh-CN.js
│ │ ├── bootstrap.min.js
│ │ ├── bootstrapValidator.min.js
│ │ ├── failed.js
│ │ └── jquery-3.3.1.min.js
│ └── templates
│ ├── azkaban
│ └── failed.html
│ └── modules
│ └── date.html
├── spring-boot-async
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── async
│ │ │ ├── Application.java
│ │ │ ├── UDFThreadPoolApplication.java
│ │ │ └── async
│ │ │ ├── Task.java
│ │ │ └── Task2.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── async
│ ├── ApplicationTests.java
│ └── UDFThreadPoolApplicationTest.java
├── spring-boot-config
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── config
│ │ │ ├── Application.java
│ │ │ └── model
│ │ │ └── BlogProperties.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── config
│ └── ApplicationTests.java
├── spring-boot-datasource-jpa
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── datasourcejpa
│ │ │ ├── Application.java
│ │ │ ├── config
│ │ │ ├── DataSourceConfig.java
│ │ │ ├── MysqlConfig.java
│ │ │ ├── PrimaryDatasourceConfig.java
│ │ │ └── SecondDatasourceConfig.java
│ │ │ └── model
│ │ │ ├── p
│ │ │ ├── PrimaryEntity.java
│ │ │ └── PrimaryRepository.java
│ │ │ └── s
│ │ │ ├── SecondaryEntity.java
│ │ │ └── SecondaryRepository.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── datasourcejpa
│ └── ApplicationTests.java
├── spring-boot-echarts
├── README.md
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── ikeguang
│ │ └── echarts
│ │ ├── Application.java
│ │ └── web
│ │ └── HelloController.java
│ └── resources
│ └── templates
│ └── index.html
├── spring-boot-error
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com.ikeguang.error
│ │ ├── Application.java
│ │ ├── dto
│ │ └── ErrorInfo.java
│ │ ├── exception
│ │ ├── GlobalExceptionHandler.java
│ │ └── MyException.java
│ │ └── web
│ │ └── HelloController.java
│ └── resources
│ ├── application.properties
│ └── templates
│ ├── error.html
│ └── index.html
├── spring-boot-file-upload
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── upload
│ │ │ ├── Applocation.java
│ │ │ └── controller
│ │ │ ├── GlobalExceptionHandler.java
│ │ │ └── UploadController.java
│ └── resources
│ │ ├── application.properties
│ │ └── templates
│ │ ├── from_file.html
│ │ ├── upload.html
│ │ └── uploadStatus.html
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── upload
│ └── ApplicationTest.java
├── spring-boot-helloworld
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── ikeguang
│ │ └── helloworld
│ │ ├── Application.java
│ │ └── controller
│ │ └── HelloWorldController.java
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── helloworld
│ └── HelloWorldControllerTests.java
├── spring-boot-jdbc
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── jdbc
│ │ │ ├── Application.java
│ │ │ ├── model
│ │ │ └── People.java
│ │ │ └── service
│ │ │ ├── PeopleService.java
│ │ │ └── impl
│ │ │ └── PeopleServiceImpl.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── jdbc
│ └── ApplicationTest.java
├── spring-boot-jpa-thymeleaf
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── jpaThymeleaf
│ │ │ ├── Application.java
│ │ │ ├── config
│ │ │ └── MysqlConfig.java
│ │ │ ├── model
│ │ │ └── User.java
│ │ │ ├── repository
│ │ │ └── UserRepository.java
│ │ │ ├── service
│ │ │ ├── UserService.java
│ │ │ └── impl
│ │ │ │ └── UserServiceImpl.java
│ │ │ └── web
│ │ │ ├── HelloController.java
│ │ │ └── UserController.java
│ └── resources
│ │ ├── application.properties
│ │ ├── static.js
│ │ ├── jquery-3.1.1.min.js
│ │ └── page.js
│ │ ├── static
│ │ └── css
│ │ │ └── bootstrap.css
│ │ └── templates
│ │ ├── hello.html
│ │ └── user
│ │ ├── list.html
│ │ ├── userAdd.html
│ │ └── userEdit.html
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── jpaThymeleaf
│ └── ApplicationTest.java
├── spring-boot-jpa
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── jpa
│ │ │ ├── Application.java
│ │ │ ├── model
│ │ │ └── User.java
│ │ │ └── repository
│ │ │ ├── UserMutiRepository.java
│ │ │ └── UserRepository.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── jpa
│ ├── ApplicationTest.java
│ └── repository
│ ├── UserMutiRepositoryTest.java
│ └── UserRepositoryTest.java
├── spring-boot-mail
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── mail
│ │ │ ├── Application.java
│ │ │ └── service
│ │ │ ├── MailService.java
│ │ │ └── impl
│ │ │ └── MailServiceImpl.java
│ └── resources
│ │ ├── application.properties
│ │ └── templates
│ │ └── emailTemplate.html
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── mail
│ ├── ApplicationTests.java
│ └── service
│ └── MailServiceTest.java
├── spring-boot-monitor-mysql
├── monitor_table.sql
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── monitor
│ │ │ └── mysql
│ │ │ ├── Application.java
│ │ │ ├── config
│ │ │ └── MysqlConfig.java
│ │ │ ├── model
│ │ │ └── MonitorTable.java
│ │ │ ├── repository
│ │ │ └── MonitorTableRepository.java
│ │ │ ├── service
│ │ │ ├── MailService.java
│ │ │ ├── MonitorTableService.java
│ │ │ └── impl
│ │ │ │ ├── MailServiceImpl.java
│ │ │ │ └── MonitorTableServiceImpl.java
│ │ │ ├── task
│ │ │ └── SchedulerTask.java
│ │ │ ├── util
│ │ │ ├── Configuration.java
│ │ │ ├── DateUtils.java
│ │ │ └── MysqlUtils.java
│ │ │ └── web
│ │ │ └── MonitorTableController.java
│ └── resources
│ │ ├── application.properties
│ │ ├── config
│ │ └── config.xml
│ │ ├── logback.xml
│ │ ├── static.jquery
│ │ └── jquery-3.3.1.min.js
│ │ ├── static
│ │ └── css
│ │ │ └── bootstrap.css
│ │ └── templates
│ │ └── monitorTable
│ │ ├── add.html
│ │ ├── edit.html
│ │ └── list.html
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── monitor
│ └── mysql
│ ├── ApplocationTest.java
│ └── util
│ └── DateUtilTests.java
├── spring-boot-mybatis
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── mybatis
│ │ │ ├── annotation
│ │ │ ├── Application.java
│ │ │ ├── enums
│ │ │ │ └── UserSexEnum.java
│ │ │ ├── mapper
│ │ │ │ └── UserMapper.java
│ │ │ ├── model
│ │ │ │ └── User.java
│ │ │ ├── sql.sql
│ │ │ └── web
│ │ │ │ └── UserController.java
│ │ │ └── xml
│ │ │ ├── XMLApplication.java
│ │ │ ├── mapper
│ │ │ └── UserMapper.java
│ │ │ ├── model
│ │ │ └── User.java
│ │ │ └── web
│ │ │ └── UserController.java
│ └── resources
│ │ ├── application.properties
│ │ └── mybatis
│ │ ├── mapper
│ │ └── UserMapper.xml
│ │ └── mybatis-config.xml
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── mybatis
│ ├── annotation
│ └── mapper
│ │ └── UserMapperTest.java
│ └── xml
│ ├── MybatisXmlApplicationTests.java
│ ├── mapper
│ └── UserMapperTest.java
│ └── web
│ └── UserControllerTest.java
├── spring-boot-oath
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── oath
│ │ │ ├── OathApplication.java
│ │ │ ├── controller
│ │ │ └── IndexController.java
│ │ │ ├── model
│ │ │ ├── GitHubAccessModel.java
│ │ │ └── GithubUserModel.java
│ │ │ └── util
│ │ │ └── GitHubProvider.java
│ └── resources
│ │ ├── application-test.yml
│ │ ├── application.yml
│ │ └── templates
│ │ └── index.html
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── oath
│ ├── OkhttpTests.java
│ └── model
│ └── GitHubAccessModelTests.java
├── spring-boot-oauth
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── org
│ │ └── ikeguang
│ │ └── oauth
│ │ ├── OauthApplication.java
│ │ └── web
│ │ └── IndexController.java
│ └── resources
│ └── application.yml
├── spring-boot-paging
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── ikeguang
│ │ └── paging
│ │ ├── Application.java
│ │ ├── config
│ │ └── MysqlConfig.java
│ │ ├── model
│ │ └── User.java
│ │ ├── repository
│ │ └── UserRepository.java
│ │ ├── service
│ │ ├── UserService.java
│ │ └── impl
│ │ │ └── UserServiceImpl.java
│ │ └── web
│ │ ├── HelloController.java
│ │ └── UserController.java
│ └── resources
│ ├── application.properties
│ ├── static
│ └── css
│ │ └── bootstrap.css
│ └── templates
│ ├── hello.html
│ └── user
│ ├── list.html
│ ├── userAdd.html
│ └── userEdit.html
├── spring-boot-redis
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── redis
│ │ │ └── Application.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── redis
│ └── ApplicationTest.java
├── spring-boot-security
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── security
│ │ │ ├── Application.java
│ │ │ ├── config
│ │ │ └── WebSecurityConfig.java
│ │ │ └── web
│ │ │ └── HelloController.java
│ └── resources
│ │ ├── application.properties
│ │ └── templates
│ │ ├── hello.html
│ │ ├── index.html
│ │ └── login.html
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── security
│ └── ApplicationTests.java
├── spring-boot-shiro
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── shiro
│ │ │ ├── Application.java
│ │ │ ├── config
│ │ │ ├── MyShiroRealm.java
│ │ │ ├── MysqlConfig.java
│ │ │ └── ShiroConfig.java
│ │ │ ├── dao
│ │ │ └── UserInfoDao.java
│ │ │ ├── model
│ │ │ ├── SysPermission.java
│ │ │ ├── SysRole.java
│ │ │ └── UserInfo.java
│ │ │ ├── service
│ │ │ ├── UserInfoService.java
│ │ │ └── impl
│ │ │ │ └── UserInfoServiceImpl.java
│ │ │ └── web
│ │ │ ├── HomeController.java
│ │ │ └── UserInfoController.java
│ └── resources
│ │ ├── application.yml
│ │ ├── database
│ │ └── import.sql
│ │ └── templates
│ │ ├── 403.html
│ │ ├── index.html
│ │ ├── login.html
│ │ ├── userInfo.html
│ │ ├── userInfoAdd.html
│ │ └── userInfoDel.html
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── shiro
│ └── ApplicationTests.java
├── spring-boot-swagger2
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── ikeguang
│ └── swagger2
│ ├── Application.java
│ ├── Swagger2.java
│ ├── model
│ └── User.java
│ └── web
│ ├── HelloController.java
│ └── UserController.java
├── spring-boot-thymeleaf
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── thymeleaf
│ │ │ ├── Application.java
│ │ │ ├── model
│ │ │ └── User.java
│ │ │ └── web
│ │ │ ├── ExampleController.java
│ │ │ ├── HelloController.java
│ │ │ └── LayoutController.java
│ └── resources
│ │ ├── application.properties
│ │ └── templates
│ │ ├── base.html
│ │ ├── eq.html
│ │ ├── fragment.html
│ │ ├── hello.html
│ │ ├── home.html
│ │ ├── if.html
│ │ ├── index.html
│ │ ├── layout.html
│ │ ├── layout
│ │ ├── copyright.html
│ │ ├── footer.html
│ │ ├── header.html
│ │ └── left.html
│ │ ├── list.html
│ │ ├── string.html
│ │ ├── switch.html
│ │ └── url.html
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── thymeleaf
│ └── ApplicationTest.java
├── spring-boot-vue
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── vue
│ │ │ ├── Application.java
│ │ │ ├── Swagger2.java
│ │ │ ├── config
│ │ │ ├── MyWebConfigurer.java
│ │ │ └── MysqlConfig.java
│ │ │ ├── model
│ │ │ ├── Article.java
│ │ │ └── User2.java
│ │ │ ├── repository
│ │ │ ├── ArticleRepository.java
│ │ │ └── UserRepository.java
│ │ │ ├── result
│ │ │ ├── Result.java
│ │ │ └── ResultCode.java
│ │ │ ├── service
│ │ │ ├── IArticleService.java
│ │ │ ├── IUserService.java
│ │ │ └── impl
│ │ │ │ ├── ArticleServiceImpl.java
│ │ │ │ └── UserServiceImpl.java
│ │ │ ├── utils
│ │ │ └── ResultConfigFactory.java
│ │ │ └── web
│ │ │ ├── ArticleController.java
│ │ │ └── UserController.java
│ └── resources
│ │ ├── application-test.properties
│ │ ├── application.properties
│ │ └── logback.xml
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── vue
│ └── service
│ ├── IArticleServiceTests.java
│ └── User2ServiceTests.java
├── spring-boot-web
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── web
│ │ │ ├── Application.java
│ │ │ ├── controller
│ │ │ ├── HelloController.java
│ │ │ ├── ThymeleafController.java
│ │ │ └── UserController.java
│ │ │ ├── model
│ │ │ └── User.java
│ │ │ └── repository
│ │ │ └── UserRepository.java
│ └── resources
│ │ ├── application.properties
│ │ ├── static.images
│ │ └── favicon.png
│ │ ├── static
│ │ └── css
│ │ │ └── starter.css
│ │ └── templates
│ │ ├── hello.html
│ │ └── layout.html
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── web
│ └── model
│ └── UserRepositoryTests.java
├── sprint-boot-scheduler
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── ikeguang
│ │ │ └── scheduler
│ │ │ ├── Application.java
│ │ │ └── task
│ │ │ └── SchedulerTask.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── ikeguang
│ └── scheduler
│ └── ApplicationTest.java
└── sprint-boot-swagger3
├── pom.xml
└── src
└── main
└── java
└── com
└── ikeguang
└── swagger3
├── Swagger3.java
├── Swagger3Application.java
└── controller
└── UserController.java
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | target/
3 | *.iml
4 | logs
5 | # spring-boot-helloworld/src/main/resources/
6 | # spring-boot-web/src/main/resources/
7 | # spring-boot-web/src/test/
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # spring-boot学习笔记
2 |
3 | [SpringBoot + thymeleaf 实现分页](https://www.ikeguang.com/article/656)
--------------------------------------------------------------------------------
/VueDemo/hello-vue/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["env", {
4 | "modules": false,
5 | "targets": {
6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7 | }
8 | }],
9 | "stage-2"
10 | ],
11 | "plugins": ["transform-vue-jsx", "transform-runtime"],
12 | "env": {
13 | "test": {
14 | "presets": ["env", "stage-2"],
15 | "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"]
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/.eslintignore:
--------------------------------------------------------------------------------
1 | /build/
2 | /config/
3 | /dist/
4 | /*.js
5 | /test/unit/coverage/
6 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // https://eslint.org/docs/user-guide/configuring
2 |
3 | module.exports = {
4 | root: true,
5 | parserOptions: {
6 | parser: 'babel-eslint'
7 | },
8 | env: {
9 | browser: true,
10 | },
11 | extends: [
12 | // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
13 | // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
14 | 'plugin:vue/essential',
15 | // https://github.com/standard/standard/blob/master/docs/RULES-en.md
16 | 'standard'
17 | ],
18 | // required to lint *.vue files
19 | plugins: [
20 | 'vue'
21 | ],
22 | // add your custom rules here
23 | rules: {
24 | // allow async-await
25 | 'generator-star-spacing': 'off',
26 | // allow debugger during development
27 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
28 | "indent": ["off", 2]
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | /dist/
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | /test/unit/coverage/
8 | /test/e2e/reports/
9 | selenium-debug.log
10 |
11 | # Editor directories and files
12 | .idea
13 | .vscode
14 | *.suo
15 | *.ntvs*
16 | *.njsproj
17 | *.sln
18 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/.postcssrc.js:
--------------------------------------------------------------------------------
1 | // https://github.com/michael-ciniawsky/postcss-load-config
2 |
3 | module.exports = {
4 | "plugins": {
5 | "postcss-import": {},
6 | "postcss-url": {},
7 | // to edit target browsers: use "browserslist" field in package.json
8 | "autoprefixer": {}
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/README.md:
--------------------------------------------------------------------------------
1 | # hello-vue
2 |
3 | > A Vue.js project
4 |
5 | ## Build Setup
6 |
7 | ``` bash
8 | # install dependencies
9 | npm install
10 |
11 | # serve with hot reload at localhost:8080
12 | npm run dev
13 |
14 | # build for production with minification
15 | npm run build
16 |
17 | # build for production and view the bundle analyzer report
18 | npm run build --report
19 |
20 | # run unit tests
21 | npm run unit
22 |
23 | # run e2e tests
24 | npm run e2e
25 |
26 | # run all tests
27 | npm test
28 | ```
29 |
30 | For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
31 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/build/build.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | require('./check-versions')()
3 |
4 | process.env.NODE_ENV = 'production'
5 |
6 | const ora = require('ora')
7 | const rm = require('rimraf')
8 | const path = require('path')
9 | const chalk = require('chalk')
10 | const webpack = require('webpack')
11 | const config = require('../config')
12 | const webpackConfig = require('./webpack.prod.conf')
13 |
14 | const spinner = ora('building for production...')
15 | spinner.start()
16 |
17 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
18 | if (err) throw err
19 | webpack(webpackConfig, (err, stats) => {
20 | spinner.stop()
21 | if (err) throw err
22 | process.stdout.write(stats.toString({
23 | colors: true,
24 | modules: false,
25 | children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
26 | chunks: false,
27 | chunkModules: false
28 | }) + '\n\n')
29 |
30 | if (stats.hasErrors()) {
31 | console.log(chalk.red(' Build failed with errors.\n'))
32 | process.exit(1)
33 | }
34 |
35 | console.log(chalk.cyan(' Build complete.\n'))
36 | console.log(chalk.yellow(
37 | ' Tip: built files are meant to be served over an HTTP server.\n' +
38 | ' Opening index.html over file:// won\'t work.\n'
39 | ))
40 | })
41 | })
42 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/build/check-versions.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const chalk = require('chalk')
3 | const semver = require('semver')
4 | const packageConfig = require('../package.json')
5 | const shell = require('shelljs')
6 |
7 | function exec (cmd) {
8 | return require('child_process').execSync(cmd).toString().trim()
9 | }
10 |
11 | const versionRequirements = [
12 | {
13 | name: 'node',
14 | currentVersion: semver.clean(process.version),
15 | versionRequirement: packageConfig.engines.node
16 | }
17 | ]
18 |
19 | if (shell.which('npm')) {
20 | versionRequirements.push({
21 | name: 'npm',
22 | currentVersion: exec('npm --version'),
23 | versionRequirement: packageConfig.engines.npm
24 | })
25 | }
26 |
27 | module.exports = function () {
28 | const warnings = []
29 |
30 | for (let i = 0; i < versionRequirements.length; i++) {
31 | const mod = versionRequirements[i]
32 |
33 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
34 | warnings.push(mod.name + ': ' +
35 | chalk.red(mod.currentVersion) + ' should be ' +
36 | chalk.green(mod.versionRequirement)
37 | )
38 | }
39 | }
40 |
41 | if (warnings.length) {
42 | console.log('')
43 | console.log(chalk.yellow('To use this template, you must update following to modules:'))
44 | console.log()
45 |
46 | for (let i = 0; i < warnings.length; i++) {
47 | const warning = warnings[i]
48 | console.log(' ' + warning)
49 | }
50 |
51 | console.log()
52 | process.exit(1)
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/build/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/VueDemo/hello-vue/build/logo.png
--------------------------------------------------------------------------------
/VueDemo/hello-vue/build/vue-loader.conf.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const utils = require('./utils')
3 | const config = require('../config')
4 | const isProduction = process.env.NODE_ENV === 'production'
5 | const sourceMapEnabled = isProduction
6 | ? config.build.productionSourceMap
7 | : config.dev.cssSourceMap
8 |
9 | module.exports = {
10 | loaders: utils.cssLoaders({
11 | sourceMap: sourceMapEnabled,
12 | extract: isProduction
13 | }),
14 | cssSourceMap: sourceMapEnabled,
15 | cacheBusting: config.dev.cacheBusting,
16 | transformToRequire: {
17 | video: ['src', 'poster'],
18 | source: 'src',
19 | img: 'src',
20 | image: 'xlink:href'
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/config/dev.env.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const merge = require('webpack-merge')
3 | const prodEnv = require('./prod.env')
4 |
5 | module.exports = merge(prodEnv, {
6 | NODE_ENV: '"development"'
7 | })
8 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/config/prod.env.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | module.exports = {
3 | NODE_ENV: '"production"'
4 | }
5 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/config/test.env.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const merge = require('webpack-merge')
3 | const devEnv = require('./dev.env')
4 |
5 | module.exports = merge(devEnv, {
6 | NODE_ENV: '"testing"'
7 | })
8 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | hello-vue
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |

4 |
5 |
6 |
7 |
8 |
13 |
14 |
24 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/assets/image/apple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/VueDemo/hello-vue/src/assets/image/apple.png
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/VueDemo/hello-vue/src/assets/logo.png
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/components/About.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
{{ msg }}
4 |
5 |
6 |
7 |
17 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/components/css/qui-nav.import.css:
--------------------------------------------------------------------------------
1 | /*QUI nav*/
2 |
3 | .qui-nav{
4 | display: -webkit-box;
5 | display: -webkit-flex;
6 | display: flex;
7 | font-size: 0;
8 | text-align: center;
9 | }
10 | .qui-nav .nav-item{
11 | -webkit-flex:1;
12 | flex:1;
13 | height: 40px;
14 | line-height: 40px;
15 | position: relative;
16 | overflow: hidden;
17 | font-size: 14px;
18 | }
19 | .qui-nav .nav-item .nav-txt{
20 | display: block;
21 | position: relative;
22 | height: 100%;
23 | }
24 | .qui-nav .nav-item .nav-txt:after{
25 | content: '';
26 | display: block;
27 | position: relative;
28 | height: 4px;
29 | background-color: #ffcd00;
30 | opacity: 0;
31 | -webkit-transform: scaleX(0);
32 | transform: scaleX(0);
33 | -webkit-transition: all .2s;
34 | transition: all .2s;
35 | width: 100%;
36 | position: absolute;
37 | bottom:0;
38 | left: 0;
39 | }
40 | .qui-nav .nav-item.active{
41 | color: #ffcd00;
42 | }
43 | .qui-nav .nav-item.active .nav-txt:after{
44 | -webkit-transform: scaleX(1);
45 | transform: scaleX(1);
46 | opacity: 1;
47 | }
48 |
49 | /*active态下方不铺满*/
50 | .qui-nav.nav-type-2 .nav-item .nav-txt{
51 | display: inline-block;
52 | padding: 0 5px;
53 | }
54 |
55 | /*居中*/
56 | .qui-nav.nav-type-3{
57 | display: block;
58 | }
59 | .qui-nav.nav-type-3 .nav-item{
60 | -webkit-flex: inherit;
61 | flex: inherit;
62 | display: inline-block;
63 | width: 110px;
64 | }
65 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/components/css/reset.import.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Basic reset css for mobile
3 | * author : cheunglong
4 | */
5 | html, body, div, span, iframe, h1, h2, h3, h4, h5, h6, p, blockquote,a,address,
6 | em, img, ol, ul, li, fieldset, form, label, legend, table, tbody, tfoot, thead, tr, th, td,i,b,s {
7 | margin:0; padding:0; border:0; font-weight:inherit; font-style:inherit; font-size:100%;font-family:microsoft yahei,Helvetica,Arial,sans-serif;
8 | }
9 |
10 |
11 | ul,ol{list-style: none}
12 | a img { border:none;vertical-align: top; }
13 | a {text-decoration: none;}
14 |
15 | button {overflow:visible;padding:0;margin:0;border:0 none;background-color:transparent;font-family:microsoft yahei,Helvetica,Arial,sans-serif;}
16 | button::-moz-focus-inner { padding:0;}
17 |
18 | input[type=password] {-webkit-text-security:disc;}
19 | textarea:focus,input:focus,button:focus{outline:none;}
20 | body {word-wrap:break-word;}
21 | * {-webkit-tap-highlight-color:rgba(0,0,0,0);}
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/components/quiArrow.vue:
--------------------------------------------------------------------------------
1 |
2 | ❯
3 |
4 |
5 |
10 |
17 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/components/quiButton.vue:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
23 |
27 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/components/quiList.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{tipsText}}
4 |
5 |
6 |
7 |
8 |
34 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/components/quiNav.vue:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
46 |
47 |
51 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/main.js:
--------------------------------------------------------------------------------
1 | // The Vue build version to load with the `import` command
2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
3 | import Vue from 'vue'
4 | import App from './App'
5 | import router from './router'
6 |
7 | Vue.config.productionTip = false
8 |
9 | /* eslint-disable no-new */
10 | new Vue({
11 | el: '#app',
12 | router,
13 | components: { App },
14 | template: ''
15 | })
16 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/pages/css/index.css:
--------------------------------------------------------------------------------
1 | /*列表*/
2 | .mod-parallel{
3 | overflow: hidden;
4 | }
5 | .mod-parallel .img-list{
6 | overflow: hidden;
7 | padding-top: 8px;
8 | }
9 | .mod-parallel .img-list .img-box{
10 | height: auto;
11 | border: none;
12 | width: 33.333333%;
13 | border-right: 12px solid transparent;
14 | border-left: 12px solid transparent;
15 | float: left;
16 | margin: 0 0 8px 0;
17 | position: relative;
18 | -webkit-box-sizing: border-box;
19 | box-sizing: border-box;
20 | }
21 | .mod-parallel .img-list .img-item{
22 | display: block;
23 | width: 100%;
24 | margin: 0;
25 | background-position: 50% 50%;
26 | background-color: #19C3FF;
27 | background-repeat: no-repeat;
28 | background-size: cover;
29 | padding-top: 100%;/*宽高比*/
30 | position: relative;
31 | border-radius: 999px;
32 | }
33 | .mod-parallel .img-list.type-full{
34 | margin: 0 -1px;
35 | }
36 | .mod-parallel .img-list.type-full .img-box{
37 | border-right-width: 1px;
38 | border-left-width: 1px;
39 | margin: 0 0 2px 0;
40 | }
41 | .mod-parallel .img-list.type-full .img-item{
42 | border-radius: 0;
43 | }
44 | .mod-parallel a,
45 | .mod-parallel .page-link{
46 | position: absolute;
47 | display: block;
48 | text-align: center;
49 | height: 100%;
50 | top: 0;
51 | color: #fff;
52 | text-decoration: none;
53 | line-height: inherit;
54 | width: 100%;
55 | display: -webkit-box;
56 | -webkit-box-orient: vertical;
57 | -webkit-box-pack: center;
58 | -webkit-box-align: center;
59 | }
60 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/pages/css/reset.import.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Basic reset css for mobile
3 | * author : cheunglong
4 | */
5 | html, body, div, span, iframe, h1, h2, h3, h4, h5, h6, p, blockquote,a,address,
6 | em, img, ol, ul, li, fieldset, form, label, legend, table, tbody, tfoot, thead, tr, th, td,i,b,s {
7 | margin:0; padding:0; border:0; font-weight:inherit; font-style:inherit; font-size:100%;font-family:microsoft yahei,Helvetica,Arial,sans-serif;
8 | }
9 |
10 |
11 | ul,ol{list-style: none}
12 | a img { border:none;vertical-align: top; }
13 | a {text-decoration: none;}
14 |
15 | button {overflow:visible;padding:0;margin:0;border:0 none;background-color:transparent;font-family:microsoft yahei,Helvetica,Arial,sans-serif;}
16 | button::-moz-focus-inner { padding:0;}
17 |
18 | input[type=password] {-webkit-text-security:disc;}
19 | textarea:focus,input:focus,button:focus{outline:none;}
20 | body {word-wrap:break-word;}
21 | * {-webkit-tap-highlight-color:rgba(0,0,0,0);}
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/pages/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
21 |
22 |
23 |
26 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/pages/pageQuiButton.vue:
--------------------------------------------------------------------------------
1 | //pageQuiButton.vue
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
36 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/pages/pageQuiList.vue:
--------------------------------------------------------------------------------
1 | //index.vue
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
37 |
38 |
41 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/src/router/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Router from 'vue-router'
3 | import HelloWorld from '@/components/HelloWorld'
4 | import about from '@/components/About'
5 | import index from '../pages/index.vue'
6 | import pageQuiButton from '../pages/pageQuiButton'
7 | import pageQuiList from '../pages/pageQuiList'
8 | import quiNav from '../components/quiNav'
9 |
10 | Vue.use(Router)
11 |
12 | export default new Router({
13 | routes: [
14 | {
15 | path: '/',
16 | name: 'HelloWorld',
17 | component: HelloWorld
18 | },
19 | {
20 | path: '/about',
21 | name: 'about',
22 | component: about
23 | },
24 | {
25 | path: '/index',
26 | name: 'index',
27 | component: index
28 | },
29 | {
30 | path: '/btn',
31 | name: 'pageQuiButton',
32 | component: pageQuiButton
33 | },
34 | {
35 | path: '/nav',
36 | name: 'nav',
37 | component: quiNav
38 | },
39 | {
40 | path: '/list',
41 | name: 'pageQuiList',
42 | component: pageQuiList
43 | }
44 | ]
45 | })
46 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/static/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/VueDemo/hello-vue/static/.gitkeep
--------------------------------------------------------------------------------
/VueDemo/hello-vue/test/e2e/custom-assertions/elementCount.js:
--------------------------------------------------------------------------------
1 | // A custom Nightwatch assertion.
2 | // The assertion name is the filename.
3 | // Example usage:
4 | //
5 | // browser.assert.elementCount(selector, count)
6 | //
7 | // For more information on custom assertions see:
8 | // http://nightwatchjs.org/guide#writing-custom-assertions
9 |
10 | exports.assertion = function (selector, count) {
11 | this.message = 'Testing if element <' + selector + '> has count: ' + count
12 | this.expected = count
13 | this.pass = function (val) {
14 | return val === this.expected
15 | }
16 | this.value = function (res) {
17 | return res.value
18 | }
19 | this.command = function (cb) {
20 | var self = this
21 | return this.api.execute(function (selector) {
22 | return document.querySelectorAll(selector).length
23 | }, [selector], function (res) {
24 | cb.call(self, res)
25 | })
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/test/e2e/nightwatch.conf.js:
--------------------------------------------------------------------------------
1 | require('babel-register')
2 | var config = require('../../config')
3 |
4 | // http://nightwatchjs.org/gettingstarted#settings-file
5 | module.exports = {
6 | src_folders: ['test/e2e/specs'],
7 | output_folder: 'test/e2e/reports',
8 | custom_assertions_path: ['test/e2e/custom-assertions'],
9 |
10 | selenium: {
11 | start_process: true,
12 | server_path: require('selenium-server').path,
13 | host: '127.0.0.1',
14 | port: 4444,
15 | cli_args: {
16 | 'webdriver.chrome.driver': require('chromedriver').path
17 | }
18 | },
19 |
20 | test_settings: {
21 | default: {
22 | selenium_port: 4444,
23 | selenium_host: 'localhost',
24 | silent: true,
25 | globals: {
26 | devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port)
27 | }
28 | },
29 |
30 | chrome: {
31 | desiredCapabilities: {
32 | browserName: 'chrome',
33 | javascriptEnabled: true,
34 | acceptSslCerts: true
35 | }
36 | },
37 |
38 | firefox: {
39 | desiredCapabilities: {
40 | browserName: 'firefox',
41 | javascriptEnabled: true,
42 | acceptSslCerts: true
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/test/e2e/specs/test.js:
--------------------------------------------------------------------------------
1 | // For authoring Nightwatch tests, see
2 | // http://nightwatchjs.org/guide#usage
3 |
4 | module.exports = {
5 | 'default e2e tests': function (browser) {
6 | // automatically uses dev Server port from /config.index.js
7 | // default: http://localhost:8080
8 | // see nightwatch.conf.js
9 | const devServer = browser.globals.devServerURL
10 |
11 | browser
12 | .url(devServer)
13 | .waitForElementVisible('#app', 5000)
14 | .assert.elementPresent('.hello')
15 | .assert.containsText('h1', 'Welcome to Your Vue.js App')
16 | .assert.elementCount('img', 1)
17 | .end()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/test/unit/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "jest": true
4 | },
5 | "globals": {
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/test/unit/jest.conf.js:
--------------------------------------------------------------------------------
1 | const path = require('path')
2 |
3 | module.exports = {
4 | rootDir: path.resolve(__dirname, '../../'),
5 | moduleFileExtensions: [
6 | 'js',
7 | 'json',
8 | 'vue'
9 | ],
10 | moduleNameMapper: {
11 | '^@/(.*)$': '/src/$1'
12 | },
13 | transform: {
14 | '^.+\\.js$': '/node_modules/babel-jest',
15 | '.*\\.(vue)$': '/node_modules/vue-jest'
16 | },
17 | testPathIgnorePatterns: [
18 | '/test/e2e'
19 | ],
20 | snapshotSerializers: ['/node_modules/jest-serializer-vue'],
21 | setupFiles: ['/test/unit/setup'],
22 | mapCoverage: true,
23 | coverageDirectory: '/test/unit/coverage',
24 | collectCoverageFrom: [
25 | 'src/**/*.{js,vue}',
26 | '!src/main.js',
27 | '!src/router/index.js',
28 | '!**/node_modules/**'
29 | ]
30 | }
31 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/test/unit/setup.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 |
3 | Vue.config.productionTip = false
4 |
--------------------------------------------------------------------------------
/VueDemo/hello-vue/test/unit/specs/HelloWorld.spec.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import HelloWorld from '@/components/HelloWorld'
3 |
4 | describe('HelloWorld.vue', () => {
5 | it('should render correct contents', () => {
6 | const Constructor = Vue.extend(HelloWorld)
7 | const vm = new Constructor().$mount()
8 | expect(vm.$el.querySelector('.hello h1').textContent)
9 | .toEqual('Welcome to Your Vue.js App')
10 | })
11 | })
12 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["env", {
4 | "modules": false,
5 | "targets": {
6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7 | }
8 | }],
9 | "stage-2"
10 | ],
11 | "plugins": ["transform-vue-jsx", "transform-runtime"]
12 | }
13 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | /dist/
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Editor directories and files
9 | .idea
10 | .vscode
11 | *.suo
12 | *.ntvs*
13 | *.njsproj
14 | *.sln
15 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/.postcssrc.js:
--------------------------------------------------------------------------------
1 | // https://github.com/michael-ciniawsky/postcss-load-config
2 |
3 | module.exports = {
4 | "plugins": {
5 | "postcss-import": {},
6 | "postcss-url": {},
7 | // to edit target browsers: use "browserslist" field in package.json
8 | "autoprefixer": {}
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/README.md:
--------------------------------------------------------------------------------
1 | # springboot-vue
2 |
3 | > A Vue.js project
4 |
5 | ## Build Setup
6 |
7 | ``` bash
8 | # install dependencies
9 | npm install
10 |
11 | # serve with hot reload at localhost:8080
12 | npm run dev
13 |
14 | # build for production with minification
15 | npm run build
16 |
17 | # build for production and view the bundle analyzer report
18 | npm run build --report
19 | ```
20 |
21 | For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
22 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/build/build.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | require('./check-versions')()
3 |
4 | process.env.NODE_ENV = 'production'
5 |
6 | const ora = require('ora')
7 | const rm = require('rimraf')
8 | const path = require('path')
9 | const chalk = require('chalk')
10 | const webpack = require('webpack')
11 | const config = require('../config')
12 | const webpackConfig = require('./webpack.prod.conf')
13 |
14 | const spinner = ora('building for production...')
15 | spinner.start()
16 |
17 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
18 | if (err) throw err
19 | webpack(webpackConfig, (err, stats) => {
20 | spinner.stop()
21 | if (err) throw err
22 | process.stdout.write(stats.toString({
23 | colors: true,
24 | modules: false,
25 | children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
26 | chunks: false,
27 | chunkModules: false
28 | }) + '\n\n')
29 |
30 | if (stats.hasErrors()) {
31 | console.log(chalk.red(' Build failed with errors.\n'))
32 | process.exit(1)
33 | }
34 |
35 | console.log(chalk.cyan(' Build complete.\n'))
36 | console.log(chalk.yellow(
37 | ' Tip: built files are meant to be served over an HTTP server.\n' +
38 | ' Opening index.html over file:// won\'t work.\n'
39 | ))
40 | })
41 | })
42 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/build/check-versions.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const chalk = require('chalk')
3 | const semver = require('semver')
4 | const packageConfig = require('../package.json')
5 | const shell = require('shelljs')
6 |
7 | function exec (cmd) {
8 | return require('child_process').execSync(cmd).toString().trim()
9 | }
10 |
11 | const versionRequirements = [
12 | {
13 | name: 'node',
14 | currentVersion: semver.clean(process.version),
15 | versionRequirement: packageConfig.engines.node
16 | }
17 | ]
18 |
19 | if (shell.which('npm')) {
20 | versionRequirements.push({
21 | name: 'npm',
22 | currentVersion: exec('npm --version'),
23 | versionRequirement: packageConfig.engines.npm
24 | })
25 | }
26 |
27 | module.exports = function () {
28 | const warnings = []
29 |
30 | for (let i = 0; i < versionRequirements.length; i++) {
31 | const mod = versionRequirements[i]
32 |
33 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
34 | warnings.push(mod.name + ': ' +
35 | chalk.red(mod.currentVersion) + ' should be ' +
36 | chalk.green(mod.versionRequirement)
37 | )
38 | }
39 | }
40 |
41 | if (warnings.length) {
42 | console.log('')
43 | console.log(chalk.yellow('To use this template, you must update following to modules:'))
44 | console.log()
45 |
46 | for (let i = 0; i < warnings.length; i++) {
47 | const warning = warnings[i]
48 | console.log(' ' + warning)
49 | }
50 |
51 | console.log()
52 | process.exit(1)
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/build/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/VueDemo/springboot-vue/build/logo.png
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/build/vue-loader.conf.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const utils = require('./utils')
3 | const config = require('../config')
4 | const isProduction = process.env.NODE_ENV === 'production'
5 | const sourceMapEnabled = isProduction
6 | ? config.build.productionSourceMap
7 | : config.dev.cssSourceMap
8 |
9 | module.exports = {
10 | loaders: utils.cssLoaders({
11 | sourceMap: sourceMapEnabled,
12 | extract: isProduction
13 | }),
14 | cssSourceMap: sourceMapEnabled,
15 | cacheBusting: config.dev.cacheBusting,
16 | transformToRequire: {
17 | video: ['src', 'poster'],
18 | source: 'src',
19 | img: 'src',
20 | image: 'xlink:href'
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/config/dev.env.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const merge = require('webpack-merge')
3 | const prodEnv = require('./prod.env')
4 |
5 | module.exports = merge(prodEnv, {
6 | NODE_ENV: '"development"'
7 | })
8 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/config/prod.env.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | module.exports = {
3 | NODE_ENV: '"production"'
4 | }
5 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | springboot-vue
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
15 |
16 |
28 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/src/assets/LOGO.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/VueDemo/springboot-vue/src/assets/LOGO.jpg
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/VueDemo/springboot-vue/src/assets/logo.png
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/src/components/article/UserArticles.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | 用户文章列表
4 |
5 |
6 |
7 |
12 |
13 |
20 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/src/components/common/Footer.vue:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
12 |
13 |
25 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/src/components/common/NavMenu.vue:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
39 |
40 |
52 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/src/components/common/about.vue:
--------------------------------------------------------------------------------
1 |
2 | about
3 |
4 |
5 |
11 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/src/components/home/Index.vue:
--------------------------------------------------------------------------------
1 |
2 | index page
3 |
4 |
5 |
11 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/src/components/user/HeaderUser.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
{{user.userName}}
7 |

8 |
9 |
10 |
11 |
12 |
13 |
26 |
27 |
46 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/src/components/user/UserInfo.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | 用户信息
4 |
5 |
6 |
7 |
12 |
13 |
20 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/src/components/user/UserNav.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{ item.navItem }}
6 |
7 |
8 |
9 |
10 |
11 |
36 |
37 |
50 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/src/components/user/UserProfile.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
18 |
19 |
29 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/src/main.js:
--------------------------------------------------------------------------------
1 | // The Vue build version to load with the `import` command
2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
3 | import Vue from 'vue'
4 | import App from './App'
5 | import router from './router'
6 |
7 | import ElementUi from 'element-ui'
8 | import 'element-ui/lib/theme-chalk/index.css'
9 | import mavonEditor from "mavon-editor";
10 | import "mavon-editor/dist/css/index.css";
11 |
12 | Vue.use(ElementUi)
13 | Vue.use(mavonEditor)
14 |
15 | var axios = require('axios')
16 | axios.defaults.baseURL = 'http://localhost:8043/api'
17 |
18 | Vue.prototype.$axios = axios
19 | Vue.config.productionTip = false
20 |
21 | new Vue({
22 | el: '#app',
23 | router,
24 | components: { App },
25 | template: ''
26 | })
27 |
--------------------------------------------------------------------------------
/VueDemo/springboot-vue/static/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/VueDemo/springboot-vue/static/.gitkeep
--------------------------------------------------------------------------------
/spring-boot-ajax/src/main/java/com/ikeguang/ajax/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.ajax;
2 |
3 | import org.mybatis.spring.annotation.MapperScan;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 |
7 | /**
8 | * @Author: keguang
9 | * @Date: 2019/7/25 10:42
10 | * @version: v1.0.0
11 | * @description:
12 | */
13 | @SpringBootApplication
14 | @MapperScan("com.ikeguang.ajax.dao")
15 | public class Application {
16 |
17 | public static void main(String[] args) {
18 | SpringApplication.run(Application.class, args);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-ajax/src/main/java/com/ikeguang/ajax/config/MysqlConfig.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.ajax.config;
2 |
3 | import org.hibernate.dialect.MySQL5Dialect;
4 | import org.springframework.stereotype.Component;
5 |
6 | /**
7 | * @Author: keguang
8 | * @Date: 2019/7/16 9:58
9 | * @version: v1.0.0
10 | * @description: 解决hibernate自动建表字符集为latin不能插入中文的问题。
11 | */
12 | @Component
13 | @SuppressWarnings("deprecation")
14 | public class MysqlConfig extends MySQL5Dialect{
15 |
16 | @Override
17 | public String getTableTypeString() {
18 | return "ENGINE=InnoDB DEFAULT CHARSET=utf8";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-ajax/src/main/java/com/ikeguang/ajax/dao/ExecutionJobsMapper.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.ajax.dao;
2 |
3 |
4 |
5 | import com.ikeguang.ajax.model.ExecutionJobs;
6 |
7 | import java.util.List;
8 | import java.util.Map;
9 |
10 | /**
11 | * @Author: keguang
12 | * @Date: 2019/12/24 14:56
13 | * @version: v1.0.0
14 | * @description:
15 | */
16 | public interface ExecutionJobsMapper {
17 |
18 | /**
19 | * 返回失败的azkaban任务
20 | * @param param
21 | * @return
22 | */
23 | List getFailedList(Map param);
24 | }
25 |
--------------------------------------------------------------------------------
/spring-boot-ajax/src/main/java/com/ikeguang/ajax/model/ExecutionJobs.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.ajax.model;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.ToString;
7 |
8 | import javax.persistence.Column;
9 | import javax.persistence.Entity;
10 | import javax.persistence.Id;
11 |
12 | /**
13 | * @Author: keguang
14 | * @Date: 2019/12/13 14:01
15 | * @version: v1.0.0
16 | * @description: azkaban 执行job实体
17 | */
18 | @AllArgsConstructor
19 | @NoArgsConstructor
20 | @Data
21 | @ToString
22 | @Entity
23 | public class ExecutionJobs {
24 |
25 | @Id
26 | private long execId;
27 | private long projectId;
28 | private long version;
29 | private String flowId;
30 | private String jobId;
31 | private int attempt;
32 | private long startTime;
33 | private long endTime;
34 |
35 | @Column(name = "status", columnDefinition = "tinyint(4)")
36 | private byte status;
37 |
38 | @Column(name="input_params", columnDefinition="longblob", nullable=true)
39 | private byte[] inputParams;
40 |
41 | @Column(name="output_params", columnDefinition="longblob", nullable=true)
42 | private byte[] outputParams;
43 |
44 | @Column(name="attachments", columnDefinition="longblob", nullable=true)
45 | private byte[] attachments;
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/spring-boot-ajax/src/main/java/com/ikeguang/ajax/model/SelectDate.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.ajax.model;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.ToString;
7 | import org.springframework.format.annotation.DateTimeFormat;
8 |
9 | import java.io.Serializable;
10 | import java.util.Date;
11 |
12 | /**
13 | * @Author: keguang
14 | * @Date: 2019/12/16 17:48
15 | * @version: v1.0.0
16 | * @description:
17 | */
18 | @Data
19 | @AllArgsConstructor
20 | @NoArgsConstructor
21 | @ToString
22 | public class SelectDate implements Serializable{
23 |
24 | @DateTimeFormat(pattern = "yyyy-MM-dd")
25 | private Date beginDate;
26 |
27 | @DateTimeFormat(pattern = "yyyy-MM-dd")
28 | private Date endDate;
29 | }
30 |
--------------------------------------------------------------------------------
/spring-boot-ajax/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=true
2 | spring.datasource.username=root
3 | spring.datasource.password=root
4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
5 |
6 | spring.jpa.properties.hibernate.hbm2ddl.auto=update
7 | spring.jpa.properties.hibernate.dialect=com.ikeguang.ajax.config.MysqlConfig
8 | spring.jpa.show-sql= true
9 |
10 | spring.thymeleaf.cache=false
11 |
12 | mybatis.type-aliases-package=com.ikeguang.ajax.model
13 | mybatis.config-location=classpath:mybatis/mybatis-config.xml
14 | mybatis.mapper-locations=classpath:mybatis/mapper/*.xml
15 |
16 | # \u7AEF\u53E3
17 | server.port=8080
--------------------------------------------------------------------------------
/spring-boot-ajax/src/main/resources/mybatis/mybatis-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/spring-boot-ajax/src/main/resources/static/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/spring-boot-ajax/src/main/resources/static/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/spring-boot-ajax/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/spring-boot-ajax/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/spring-boot-ajax/src/main/resources/static/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/spring-boot-ajax/src/main/resources/static/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/spring-boot-ajax/src/main/resources/static/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/spring-boot-ajax/src/main/resources/static/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/spring-boot-ajax/src/main/resources/static/js/bootstrap-datepicker.zh-CN.min.js:
--------------------------------------------------------------------------------
1 | !function(a){a.fn.datepicker.dates["zh-CN"]={days:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],daysShort:["周日","周一","周二","周三","周四","周五","周六"],daysMin:["日","一","二","三","四","五","六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],monthsShort:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],today:"今天",monthsTitle:"选择月份",clear:"清除",format:"yyyy-mm-dd",titleFormat:"yyyy年mm月",weekStart:1}}(jQuery);
--------------------------------------------------------------------------------
/spring-boot-ajax/src/main/resources/static/js/bootstrap-datetimepicker.zh-CN.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Simplified Chinese translation for bootstrap-datetimepicker
3 | * Yuan Cheung
4 | */
5 | ;(function($){
6 | $.fn.datetimepicker.dates['zh-CN'] = {
7 | days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
8 | daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
9 | daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
10 | months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
11 | monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
12 | today: "今天",
13 | suffix: [],
14 | meridiem: ["上午", "下午"]
15 | };
16 | }(jQuery));
17 |
--------------------------------------------------------------------------------
/spring-boot-async/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-learn
7 | com.ikeguang
8 | 1.0.0
9 |
10 | 4.0.0
11 |
12 | spring-boot-async
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-test
23 | test
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/spring-boot-async/src/main/java/com/ikeguang/async/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.async;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.scheduling.annotation.EnableAsync;
6 |
7 | /**
8 | * @ Author: keguang
9 | * @ Date: 2019/8/19 16:07
10 | * @ version: v1.0.0
11 | * @ description:
12 | */
13 | @SpringBootApplication
14 | @EnableAsync
15 | public class Application {
16 |
17 | public static void main(String[] args) {
18 | SpringApplication.run(Application.class, args);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-async/src/main/java/com/ikeguang/async/async/Task2.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.async.async;
2 |
3 | import lombok.extern.slf4j.Slf4j;
4 | import org.springframework.scheduling.annotation.Async;
5 | import org.springframework.stereotype.Component;
6 |
7 | import java.util.Random;
8 |
9 | /**
10 | * @ Author: keguang
11 | * @ Date: 2019/8/28 17:40
12 | * @ version: v1.0.0
13 | * @ description:
14 | */
15 | @Slf4j
16 | @Component
17 | public class Task2 {
18 |
19 | public static Random random = new Random();
20 |
21 | @Async("taskExecutor")
22 | public void doTaskOne() throws InterruptedException {
23 | log.info("开始做任务一");
24 | long start = System.currentTimeMillis();
25 | Thread.sleep(random.nextInt(10000));
26 | long end = System.currentTimeMillis();
27 | log.info("完成任务一,耗时:" + (end - start) + "毫秒");
28 | }
29 |
30 | @Async("taskExecutor")
31 | public void doTaskTwo() throws InterruptedException {
32 | log.info("开始做任务二");
33 | long start = System.currentTimeMillis();
34 | Thread.sleep(random.nextInt(10000));
35 | long end = System.currentTimeMillis();
36 | log.info("完成任务二,耗时:" + (end - start) + "毫秒");
37 | }
38 |
39 | @Async("taskExecutor")
40 | public void doTaskThree() throws InterruptedException {
41 | log.info("开始做任务三");
42 | long start = System.currentTimeMillis();
43 | Thread.sleep(random.nextInt(10000));
44 | long end = System.currentTimeMillis();
45 | log.info("完成任务三,耗时:" + (end - start) + "毫秒");
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/spring-boot-async/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/spring-boot-async/src/main/resources/application.properties
--------------------------------------------------------------------------------
/spring-boot-async/src/test/java/com/ikeguang/async/ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.async;
2 |
3 | import com.ikeguang.async.async.Task;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.context.SpringBootTest;
8 | import org.springframework.test.context.junit4.SpringRunner;
9 |
10 | import java.util.concurrent.Future;
11 |
12 | /**
13 | * @ Author: keguang
14 | * @ Date: 2019/8/19 16:03
15 | * @ version: v1.0.0
16 | * @ description:
17 | */
18 | @RunWith(SpringRunner.class)
19 | @SpringBootTest
20 | public class ApplicationTests {
21 |
22 | @Autowired
23 | private Task task;
24 |
25 | @Test
26 | public void test() throws InterruptedException {
27 | long start = System.currentTimeMillis();
28 |
29 | Future task1 = task.doTaskOne();
30 | Future task2 = task.doTaskTwo();
31 | Future task3 = task.doTaskThree();
32 |
33 |
34 | while (true){
35 | if(task1.isDone() && task2.isDone() && task3.isDone()){
36 | break;
37 | }
38 |
39 | // 一秒钟检查一次
40 | Thread.sleep(1000);
41 | }
42 |
43 | long end = System.currentTimeMillis();
44 |
45 | System.out.println("任务全部完成,耗时:" + (end - start) + "毫秒");
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/spring-boot-async/src/test/java/com/ikeguang/async/UDFThreadPoolApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.async;
2 |
3 | import com.ikeguang.async.async.Task2;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.context.SpringBootTest;
8 | import org.springframework.test.context.junit4.SpringRunner;
9 |
10 | /**
11 | * @ Author: keguang
12 | * @ Date: 2019/8/28 17:49
13 | * @ version: v1.0.0
14 | * @ description:
15 | */
16 | @RunWith(SpringRunner.class)
17 | @SpringBootTest
18 | public class UDFThreadPoolApplicationTest {
19 |
20 | @Autowired
21 | private Task2 task2;
22 |
23 | @Test
24 | public void test() throws InterruptedException {
25 | task2.doTaskOne();
26 | task2.doTaskTwo();
27 | task2.doTaskThree();
28 |
29 | Thread.currentThread().join();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/spring-boot-config/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-learn
7 | com.ikeguang
8 | 1.0.0
9 |
10 | 4.0.0
11 |
12 | spring-boot-config
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-starter-web
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-test
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-devtools
30 | true
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/spring-boot-config/src/main/java/com/ikeguang/config/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.config;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Application {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(Application.class, args);
11 | }
12 |
13 | }
--------------------------------------------------------------------------------
/spring-boot-config/src/main/java/com/ikeguang/config/model/BlogProperties.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.config.model;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.stereotype.Component;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/8/12 17:09
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 | @Component
13 | public class BlogProperties {
14 |
15 | @Value("${com.didispace.blog.name}")
16 | private String name;
17 | @Value("${com.didispace.blog.title}")
18 | private String title;
19 |
20 | public String getName() {
21 | return name;
22 | }
23 |
24 | public void setName(String name) {
25 | this.name = name;
26 | }
27 |
28 | public String getTitle() {
29 | return title;
30 | }
31 |
32 | public void setTitle(String title) {
33 | this.title = title;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/spring-boot-config/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | com.didispace.blog.name=程序猿DD
2 | com.didispace.blog.title=Spring Boot教程
3 | com.didispace.blog.desc=${com.didispace.blog.name}正在努力写《${com.didispace.blog.title}》
4 |
5 | # 随机字符串
6 | com.didispace.blog.value=${random.value}
7 | # 随机int
8 | com.didispace.blog.number=${random.int}
9 | # 随机long
10 | com.didispace.blog.bignumber=${random.long}
11 | # 10以内的随机数
12 | com.didispace.blog.test1=${random.int(10)}
13 | # 10-20的随机数
14 | com.didispace.blog.test2=${random.int[10,20]}
15 |
16 | # 多环境配置文件激活属性
17 | spring.profiles.active=dev
--------------------------------------------------------------------------------
/spring-boot-config/src/test/java/com/ikeguang/config/ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.config;
2 |
3 | import com.ikeguang.config.model.BlogProperties;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.context.SpringBootTest;
8 | import org.springframework.test.context.junit4.SpringRunner;
9 |
10 | /**
11 | * @ Author: keguang
12 | * @ Date: 2019/8/12 17:11
13 | * @ version: v1.0.0
14 | * @ description:
15 | */
16 | @RunWith(SpringRunner.class)
17 | @SpringBootTest
18 | public class ApplicationTests {
19 |
20 | @Autowired
21 | private BlogProperties blogProperties;
22 |
23 | @Test
24 | public void getHello(){
25 | System.out.println(blogProperties.getTitle());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/spring-boot-datasource-jpa/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-learn
7 | com.ikeguang
8 | 1.0.0
9 |
10 | 4.0.0
11 |
12 | spring-boot-datasource-jpa
13 |
14 |
15 |
16 |
17 | org.springframework.boot
18 | spring-boot-starter-test
19 | test
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-data-jpa
24 |
25 |
26 | mysql
27 | mysql-connector-java
28 |
29 |
30 |
--------------------------------------------------------------------------------
/spring-boot-datasource-jpa/src/main/java/com/ikeguang/datasourcejpa/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.datasourcejpa;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/25 10:42
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 | @SpringBootApplication
13 | public class Application {
14 |
15 | public static void main(String[] args) {
16 | SpringApplication.run(Application.class, args);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/spring-boot-datasource-jpa/src/main/java/com/ikeguang/datasourcejpa/config/DataSourceConfig.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.datasourcejpa.config;
2 |
3 | import org.springframework.beans.factory.annotation.Qualifier;
4 | import org.springframework.boot.context.properties.ConfigurationProperties;
5 | import org.springframework.boot.jdbc.DataSourceBuilder;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 | import org.springframework.context.annotation.Primary;
9 |
10 | import javax.sql.DataSource;
11 |
12 | /**
13 | * @ Author: keguang
14 | * @ Date: 2019/12/17 14:48
15 | * @ version: v1.0.0
16 | * @ description:
17 | */
18 | @Configuration
19 | public class DataSourceConfig {
20 |
21 | @Bean(name = "primaryDataSource")
22 | @Primary
23 | @Qualifier("primaryDataSource")
24 | @ConfigurationProperties(prefix = "spring.datasource.primary")
25 | public DataSource primaryDataSource(){
26 | return DataSourceBuilder.create().build();
27 | }
28 |
29 | @Bean(name = "secondaryDataSource")
30 | @Qualifier("secondaryDataSource")
31 | @ConfigurationProperties(prefix = "spring.datasource.secondary")
32 | public DataSource secondaryDataSource(){
33 | return DataSourceBuilder.create().build();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/spring-boot-datasource-jpa/src/main/java/com/ikeguang/datasourcejpa/config/MysqlConfig.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.datasourcejpa.config;
2 |
3 | import org.hibernate.dialect.MySQL5Dialect;
4 | import org.springframework.stereotype.Component;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/16 9:58
9 | * @ version: v1.0.0
10 | * @ description: 解决hibernate自动建表字符集为latin不能插入中文的问题。
11 | */
12 | @Component
13 | @SuppressWarnings("deprecation")
14 | public class MysqlConfig extends MySQL5Dialect{
15 |
16 | @Override
17 | public String getTableTypeString() {
18 | return "ENGINE=InnoDB DEFAULT CHARSET=utf8";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-datasource-jpa/src/main/java/com/ikeguang/datasourcejpa/model/p/PrimaryEntity.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.datasourcejpa.model.p;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.ToString;
7 |
8 | import javax.persistence.Column;
9 | import javax.persistence.Entity;
10 | import javax.persistence.GeneratedValue;
11 | import javax.persistence.Id;
12 |
13 | /**
14 | * @ Author: keguang
15 | * @ Date: 2019/12/17 15:06
16 | * @ version: v1.0.0
17 | * @ description:
18 | */
19 | @AllArgsConstructor
20 | @NoArgsConstructor
21 | @Data
22 | @ToString
23 | @Entity
24 | public class PrimaryEntity {
25 |
26 | @Id
27 | @GeneratedValue
28 | private long id;
29 |
30 | @Column(nullable = false)
31 | private String name;
32 | }
33 |
--------------------------------------------------------------------------------
/spring-boot-datasource-jpa/src/main/java/com/ikeguang/datasourcejpa/model/p/PrimaryRepository.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.datasourcejpa.model.p;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | /**
6 | * @ Author: keguang
7 | * @ Date: 2019/12/17 15:08
8 | * @ version: v1.0.0
9 | * @ description:
10 | */
11 | public interface PrimaryRepository extends JpaRepository {
12 | }
13 |
--------------------------------------------------------------------------------
/spring-boot-datasource-jpa/src/main/java/com/ikeguang/datasourcejpa/model/s/SecondaryEntity.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.datasourcejpa.model.s;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.ToString;
7 |
8 | import javax.persistence.Column;
9 | import javax.persistence.Entity;
10 | import javax.persistence.GeneratedValue;
11 | import javax.persistence.Id;
12 |
13 | /**
14 | * @ Author: keguang
15 | * @ Date: 2019/12/17 15:09
16 | * @ version: v1.0.0
17 | * @ description:
18 | */
19 | @AllArgsConstructor
20 | @NoArgsConstructor
21 | @Data
22 | @ToString
23 | @Entity
24 | public class SecondaryEntity {
25 |
26 | @Id
27 | @GeneratedValue
28 | private long id;
29 |
30 | @Column(nullable = false)
31 | private String name;
32 | }
33 |
--------------------------------------------------------------------------------
/spring-boot-datasource-jpa/src/main/java/com/ikeguang/datasourcejpa/model/s/SecondaryRepository.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.datasourcejpa.model.s;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | /**
6 | * @ Author: keguang
7 | * @ Date: 2019/12/17 16:16
8 | * @ version: v1.0.0
9 | * @ description:
10 | */
11 | public interface SecondaryRepository extends JpaRepository{
12 | }
13 |
--------------------------------------------------------------------------------
/spring-boot-datasource-jpa/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.primary.jdbc-url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=true
2 | spring.datasource.primary.username=root
3 | spring.datasource.primary.password=root
4 | spring.datasource.primary.driver-class-name=com.mysql.cj.jdbc.Driver
5 |
6 | spring.datasource.secondary.jdbc-url=jdbc:mysql://localhost:3306/test2?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=true
7 | spring.datasource.secondary.username=root
8 | spring.datasource.secondary.password=root
9 | spring.datasource.secondary.driver-class-name=com.mysql.cj.jdbc.Driver
10 |
11 | spring.jpa.properties.hibernate.hbm2ddl.auto=update
12 | spring.jpa.properties.hibernate.dialect=com.ikeguang.datasourcejpa.config.MysqlConfig
13 | spring.jpa.show-sql= true
--------------------------------------------------------------------------------
/spring-boot-echarts/README.md:
--------------------------------------------------------------------------------
1 | # 官方文档
2 | https://www.echartsjs.com/zh/api.html#echarts
--------------------------------------------------------------------------------
/spring-boot-echarts/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-learn
7 | com.ikeguang
8 | 1.0.0
9 |
10 | 4.0.0
11 |
12 | spring-boot-echarts
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter-web
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-starter-thymeleaf
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-test
26 | test
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/spring-boot-echarts/src/main/java/com/ikeguang/echarts/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.echarts;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * @Author: keguang
8 | * @Date: 2020/4/15 16:57
9 | * @version: v1.0.0
10 | * @description:
11 | */
12 | @SpringBootApplication
13 | public class Application {
14 |
15 | public static void main(String[] args) {
16 | SpringApplication.run(Application.class, args);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/spring-boot-echarts/src/main/java/com/ikeguang/echarts/web/HelloController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.echarts.web;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.ui.ModelMap;
5 | import org.springframework.web.bind.annotation.GetMapping;
6 |
7 | /**
8 | * @Author: keguang
9 | * @Date: 2020/4/15 17:02
10 | * @version: v1.0.0
11 | * @description:
12 | */
13 | @Controller
14 | public class HelloController {
15 |
16 | @GetMapping("/")
17 | public String index(ModelMap map){
18 | return "index";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-echarts/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Spring Boot中使用ECharts
6 |
7 |
8 |
9 |
10 |
11 |
12 |
41 |
--------------------------------------------------------------------------------
/spring-boot-error/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-learn
7 | com.ikeguang
8 | 1.0.0
9 |
10 | 4.0.0
11 |
12 | spring-boot-error
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter-test
18 | test
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-web
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter-thymeleaf
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/spring-boot-error/src/main/java/com.ikeguang.error/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.error;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/8/6 9:34
9 | * @ version: v1.0.0
10 | * @ description: SpringBoot统一异常处理
11 | */
12 | @SpringBootApplication
13 | public class Application {
14 |
15 | public static void main(String[] args) {
16 | SpringApplication.run(Application.class, args);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/spring-boot-error/src/main/java/com.ikeguang.error/dto/ErrorInfo.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.error.dto;
2 |
3 | import javax.swing.plaf.PanelUI;
4 |
5 | /**
6 | * @ Author: keguang
7 | * @ Date: 2019/8/6 9:48
8 | * @ version: v1.0.0
9 | * @ description:
10 | */
11 | public class ErrorInfo {
12 |
13 | public static final Integer OK = 0;
14 | public static final Integer ERROR = 100;
15 |
16 | private Integer code;
17 | private String message;
18 | private String url;
19 | private T data;
20 |
21 | public Integer getCode() {
22 | return code;
23 | }
24 |
25 | public void setCode(Integer code) {
26 | this.code = code;
27 | }
28 |
29 | public String getMessage() {
30 | return message;
31 | }
32 |
33 | public void setMessage(String message) {
34 | this.message = message;
35 | }
36 |
37 | public String getUrl() {
38 | return url;
39 | }
40 |
41 | public void setUrl(String url) {
42 | this.url = url;
43 | }
44 |
45 | public T getData() {
46 | return data;
47 | }
48 |
49 | public void setData(T data) {
50 | this.data = data;
51 | }
52 |
53 | public static Integer getOK() {
54 | return OK;
55 | }
56 |
57 | public static Integer getERROR() {
58 | return ERROR;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/spring-boot-error/src/main/java/com.ikeguang.error/exception/GlobalExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.error.exception;
2 |
3 | import com.ikeguang.error.dto.ErrorInfo;
4 | import org.springframework.web.bind.annotation.ControllerAdvice;
5 | import org.springframework.web.bind.annotation.ExceptionHandler;
6 | import org.springframework.web.bind.annotation.ResponseBody;
7 | import org.springframework.web.servlet.ModelAndView;
8 |
9 | import javax.servlet.http.HttpServletRequest;
10 |
11 | /**
12 | * @ Author: keguang
13 | * @ Date: 2019/8/6 9:57
14 | * @ version: v1.0.0
15 | * @ description:
16 | */
17 | @ControllerAdvice
18 | public class GlobalExceptionHandler {
19 |
20 | @ExceptionHandler(value = Exception.class)
21 | public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e){
22 | ModelAndView mav = new ModelAndView();
23 | mav.addObject("exception", e);
24 | mav.addObject("url", req.getRequestURL());
25 | mav.setViewName("error");
26 | return mav;
27 | }
28 |
29 | @ExceptionHandler(value = MyException.class)
30 | @ResponseBody // 以json格式返回数据
31 | public ErrorInfo jsonErrorHandler(HttpServletRequest req, MyException e){
32 | ErrorInfo r = new ErrorInfo<>();
33 | r.setMessage(e.getMessage());
34 | r.setCode(ErrorInfo.ERROR);
35 | r.setData("Some Data");
36 | r.setUrl(req.getRequestURL().toString());
37 | return r;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/spring-boot-error/src/main/java/com.ikeguang.error/exception/MyException.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.error.exception;
2 |
3 | /**
4 | * @ Author: keguang
5 | * @ Date: 2019/8/6 10:10
6 | * @ version: v1.0.0
7 | * @ description:
8 | */
9 | public class MyException extends Exception{
10 |
11 | public MyException(String message){
12 | super(message);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/spring-boot-error/src/main/java/com.ikeguang.error/web/HelloController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.error.web;
2 |
3 | import com.ikeguang.error.exception.MyException;
4 | import org.springframework.stereotype.Controller;
5 | import org.springframework.ui.ModelMap;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/8/6 10:20
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @Controller
15 | public class HelloController {
16 |
17 | @RequestMapping("/hello")
18 | public String hello() throws Exception {
19 | throw new Exception("发生错误");
20 | }
21 |
22 | @RequestMapping("/json")
23 | public String json() throws MyException {
24 | throw new MyException("发生错误2");
25 | }
26 |
27 | @RequestMapping("/")
28 | public String index(ModelMap map){
29 | map.addAttribute("host", "http://www.ikeguang.com");
30 | return "index";
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/spring-boot-error/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/spring-boot-error/src/main/resources/application.properties
--------------------------------------------------------------------------------
/spring-boot-error/src/main/resources/templates/error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 统一异常处理
6 |
7 |
8 | Error Handler
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/spring-boot-error/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Hello World
9 |
10 |
--------------------------------------------------------------------------------
/spring-boot-file-upload/src/main/java/com/ikeguang/upload/Applocation.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.upload;
2 |
3 | import org.apache.coyote.http11.AbstractHttp11Protocol;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
7 | import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
8 | import org.springframework.context.annotation.Bean;
9 |
10 | /**
11 | * @ Author: keguang
12 | * @ Date: 2019/7/22 11:23
13 | * @ version: v1.0.0
14 | * @ description:
15 | */
16 | @SpringBootApplication
17 | public class Applocation {
18 |
19 | public static void main(String[] args) {
20 | SpringApplication.run(Applocation.class, args);
21 | }
22 |
23 | @Bean
24 | public TomcatServletWebServerFactory tomcatEmbedded() {
25 | TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
26 | tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
27 | if ((connector.getProtocolHandler() instanceof AbstractHttp11Protocol>)) {
28 | //-1 means unlimited
29 | ((AbstractHttp11Protocol>) connector.getProtocolHandler()).setMaxSwallowSize(-1);
30 | }
31 | });
32 | return tomcat;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/spring-boot-file-upload/src/main/java/com/ikeguang/upload/controller/GlobalExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.upload.controller;
2 |
3 | import org.springframework.web.bind.annotation.ControllerAdvice;
4 | import org.springframework.web.bind.annotation.ExceptionHandler;
5 | import org.springframework.web.multipart.MultipartException;
6 | import org.springframework.web.servlet.mvc.support.RedirectAttributes;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/22 11:35
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @ControllerAdvice
15 | public class GlobalExceptionHandler {
16 |
17 | @ExceptionHandler(MultipartException.class)
18 | public String handleError1(MultipartException e, RedirectAttributes redirectAttributes) {
19 | redirectAttributes.addFlashAttribute("message", e.getCause().getMessage());
20 | return "redirect:/uploadStatus";
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-boot-file-upload/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.servlet.multipart.max-file-size=10MB
2 | spring.servlet.multipart.max-request-size=10MB
--------------------------------------------------------------------------------
/spring-boot-file-upload/src/main/resources/templates/upload.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Spring Boot file upload example
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/spring-boot-file-upload/src/main/resources/templates/uploadStatus.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Spring Boot - Upload Status
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/spring-boot-file-upload/src/test/java/com/ikeguang/upload/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.upload;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/22 11:26
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @RunWith(SpringRunner.class)
15 | @SpringBootTest
16 | public class ApplicationTest {
17 | @Test
18 | public void loadContext(){
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/spring-boot-helloworld/src/main/java/com/ikeguang/helloworld/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.helloworld;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Application {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(Application.class, args);
11 | }
12 |
13 | }
--------------------------------------------------------------------------------
/spring-boot-helloworld/src/main/java/com/ikeguang/helloworld/controller/HelloWorldController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.helloworld.controller;
2 |
3 | import org.springframework.web.bind.annotation.RequestMapping;
4 | import org.springframework.web.bind.annotation.RestController;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/6/19 19:57
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 |
13 | @RestController
14 | public class HelloWorldController {
15 | @RequestMapping("/hello")
16 | public String index(){
17 | return "Hello World";
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/spring-boot-helloworld/src/test/java/com/ikeguang/helloworld/HelloWorldControllerTests.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.helloworld;
2 |
3 | import com.ikeguang.helloworld.controller.HelloWorldController;
4 | import org.junit.Before;
5 | import org.junit.Test;
6 | import org.junit.runner.RunWith;
7 | import org.springframework.boot.test.context.SpringBootTest;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.test.context.junit4.SpringRunner;
10 | import org.springframework.test.web.servlet.MockMvc;
11 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
12 | import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
13 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
14 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
15 |
16 | /**
17 | * @ Author: keguang
18 | * @ Date: 2019/6/19 20:12
19 | * @ version: v1.0.0
20 | * @ description:
21 | */
22 |
23 | @RunWith(SpringRunner.class)
24 | @SpringBootTest
25 | public class HelloWorldControllerTests {
26 |
27 | private MockMvc mvc;
28 | @Before
29 | public void setUp(){
30 | mvc = MockMvcBuilders.standaloneSetup(new HelloWorldController()).build();
31 | }
32 |
33 | @Test
34 | public void getHello() throws Exception {
35 | mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON))
36 | .andExpect(MockMvcResultMatchers.status().isOk())
37 | .andDo(MockMvcResultHandlers.print())
38 | .andReturn();
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/spring-boot-jdbc/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-learn
7 | com.ikeguang
8 | 1.0.0
9 |
10 | 4.0.0
11 |
12 | spring-boot-jdbc
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-starter-web
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-test
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-jdbc
30 |
31 |
32 | mysql
33 | mysql-connector-java
34 | 8.0.16
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/spring-boot-jdbc/src/main/java/com/ikeguang/jdbc/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jdbc;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Application {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(Application.class, args);
11 | }
12 |
13 | }
--------------------------------------------------------------------------------
/spring-boot-jdbc/src/main/java/com/ikeguang/jdbc/model/People.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jdbc.model;
2 |
3 | /**
4 | * @ Author: keguang
5 | * @ Date: 2019/8/14 10:36
6 | * @ version: v1.0.0
7 | * @ description:
8 | */
9 | public class People {
10 |
11 | private String name;
12 | private Integer age;
13 |
14 | public People() {
15 | }
16 |
17 | public People(String name, Integer age) {
18 | this.name = name;
19 | this.age = age;
20 | }
21 |
22 | public String getName() {
23 | return name;
24 | }
25 |
26 | public void setName(String name) {
27 | this.name = name;
28 | }
29 |
30 | public Integer getAge() {
31 | return age;
32 | }
33 |
34 | public void setAge(Integer age) {
35 | this.age = age;
36 | }
37 |
38 | @Override
39 | public String toString() {
40 | return "People{" +
41 | "name='" + name + '\'' +
42 | ", age=" + age +
43 | '}';
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/spring-boot-jdbc/src/main/java/com/ikeguang/jdbc/service/PeopleService.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jdbc.service;
2 |
3 | /**
4 | * @ Author: keguang
5 | * @ Date: 2019/8/14 10:37
6 | * @ version: v1.0.0
7 | * @ description:
8 | */
9 | public interface PeopleService {
10 |
11 | /**
12 | * 新增一个用户
13 | * @param name
14 | * @param age
15 | */
16 | void create(String name, Integer age);
17 |
18 | /**
19 | * 根据name删除用户
20 | * @param name
21 | */
22 | void deleteByName(String name);
23 |
24 | /**
25 | * 获取所有用户
26 | */
27 | Integer getAllPeoples();
28 |
29 | /**
30 | * 删除所有用户
31 | */
32 | void deleteAllPeople();
33 | }
34 |
--------------------------------------------------------------------------------
/spring-boot-jdbc/src/main/java/com/ikeguang/jdbc/service/impl/PeopleServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jdbc.service.impl;
2 |
3 | import com.ikeguang.jdbc.service.PeopleService;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.jdbc.core.JdbcTemplate;
6 | import org.springframework.stereotype.Service;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/8/14 10:44
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @Service
15 | public class PeopleServiceImpl implements PeopleService {
16 |
17 | @Autowired
18 | private JdbcTemplate jdbcTemplate;
19 |
20 | @Override
21 | public void create(String name, Integer age) {
22 |
23 | jdbcTemplate.update("insert into people(name, age) values(?, ?)", name, age);
24 | }
25 |
26 | @Override
27 | public void deleteByName(String name) {
28 | jdbcTemplate.update("delete from people where name = ?", name);
29 | }
30 |
31 | @Override
32 | public Integer getAllPeoples() {
33 | return jdbcTemplate.queryForObject("select count(1) from people", Integer.class);
34 | }
35 |
36 | @Override
37 | public void deleteAllPeople() {
38 | jdbcTemplate.update("delete from people");
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/spring-boot-jdbc/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:mysql://localhost:3306/test
2 | spring.datasource.username=root
3 | spring.datasource.password=root
4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver
--------------------------------------------------------------------------------
/spring-boot-jpa-thymeleaf/src/main/java/com/ikeguang/jpaThymeleaf/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jpaThymeleaf;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.builder.SpringApplicationBuilder;
6 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
7 |
8 | /**
9 | * @Author: keguang
10 | * @Date: 2019/7/8 10:38
11 | * @version: v1.0.0
12 | * @description:
13 | */
14 | @SpringBootApplication
15 | public class Application extends SpringBootServletInitializer{
16 |
17 | @Override
18 | protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
19 | return builder.sources(Application.class);
20 | }
21 |
22 | public static void main(String[] args) {
23 | SpringApplication.run(Application.class, args);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/spring-boot-jpa-thymeleaf/src/main/java/com/ikeguang/jpaThymeleaf/config/MysqlConfig.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jpaThymeleaf.config;
2 |
3 | import org.hibernate.dialect.MySQL5Dialect;
4 | import org.springframework.stereotype.Component;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/16 9:58
9 | * @ version: v1.0.0
10 | * @ description: 解决hibernate自动建表字符集为latin不能插入中文的问题。
11 | */
12 | @Component
13 | @SuppressWarnings("deprecation")
14 | public class MysqlConfig extends MySQL5Dialect{
15 |
16 | @Override
17 | public String getTableTypeString() {
18 | return "ENGINE=InnoDB DEFAULT CHARSET=utf8";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-jpa-thymeleaf/src/main/java/com/ikeguang/jpaThymeleaf/repository/UserRepository.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jpaThymeleaf.repository;
2 |
3 | import com.ikeguang.jpaThymeleaf.model.User;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.data.jpa.repository.Query;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * @ Author: keguang
11 | * @ Date: 2019/7/18 10:23
12 | * @ version: v1.0.0
13 | * @ description:
14 | */
15 | public interface UserRepository extends JpaRepository{
16 |
17 | User findById(long id);
18 |
19 | void deleteById(long id);
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-jpa-thymeleaf/src/main/java/com/ikeguang/jpaThymeleaf/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jpaThymeleaf.service;
2 |
3 | import com.ikeguang.jpaThymeleaf.model.User;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * @ Author: keguang
9 | * @ Date: 2019/7/18 10:26
10 | * @ version: v1.0.0
11 | * @ description:
12 | */
13 | public interface UserService {
14 |
15 | public List getUserList();
16 |
17 | public User findUserById(long id);
18 |
19 | public void save(User user);
20 |
21 | public void edit(User user);
22 |
23 | public void delete(long id);
24 | }
25 |
--------------------------------------------------------------------------------
/spring-boot-jpa-thymeleaf/src/main/java/com/ikeguang/jpaThymeleaf/service/impl/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jpaThymeleaf.service.impl;
2 |
3 | import com.github.pagehelper.Page;
4 | import com.ikeguang.jpaThymeleaf.model.User;
5 | import com.ikeguang.jpaThymeleaf.repository.UserRepository;
6 | import com.ikeguang.jpaThymeleaf.service.UserService;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.stereotype.Service;
9 |
10 | import java.util.HashMap;
11 | import java.util.List;
12 | import java.util.Map;
13 |
14 | /**
15 | * @ Author: keguang
16 | * @ Date: 2019/7/18 10:27
17 | * @ version: v1.0.0
18 | * @ description:
19 | */
20 | @Service
21 | public class UserServiceImpl implements UserService {
22 | @Autowired
23 | private UserRepository userRepository;
24 |
25 | @Override
26 | public List getUserList() {
27 |
28 | return userRepository.findAll();
29 | }
30 |
31 | @Override
32 | public User findUserById(long id) {
33 | return userRepository.findById(id);
34 | }
35 |
36 | @Override
37 | public void save(User user) {
38 | userRepository.save(user);
39 | }
40 |
41 | @Override
42 | public void edit(User user) {
43 | userRepository.save(user);
44 | }
45 |
46 | @Override
47 | public void delete(long id) {
48 | userRepository.deleteById(id);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/spring-boot-jpa-thymeleaf/src/main/java/com/ikeguang/jpaThymeleaf/web/HelloController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jpaThymeleaf.web;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.ui.Model;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RequestParam;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/18 10:29
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @Controller
15 | public class HelloController {
16 |
17 | @RequestMapping("/hello")
18 | public String hello(Model model, @RequestParam(value = "name", required = false, defaultValue = "world") String name){
19 | model.addAttribute("name", name);
20 |
21 | return "hello";
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/spring-boot-jpa-thymeleaf/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=true
2 | spring.datasource.username=root
3 | spring.datasource.password=root
4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
5 |
6 | spring.jpa.properties.hibernate.hbm2ddl.auto=update
7 | spring.jpa.properties.hibernate.dialect=com.ikeguang.jpaThymeleaf.config.MysqlConfig
8 | spring.jpa.show-sql= true
9 |
10 | spring.thymeleaf.cache=false
--------------------------------------------------------------------------------
/spring-boot-jpa-thymeleaf/src/main/resources/templates/hello.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Hello Thymeleaf!
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/spring-boot-jpa-thymeleaf/src/test/java/com/ikeguang/jpaThymeleaf/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jpaThymeleaf;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/17 18:06
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @RunWith(SpringRunner.class)
15 | @SpringBootTest
16 | public class ApplicationTest {
17 |
18 | @Test
19 | public void loadContext(){
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-boot-jpa/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-learn
7 | com.ikeguang
8 | 1.0.0
9 |
10 | 4.0.0
11 |
12 | spring-boot-jpa
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter-test
18 | test
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-data-jpa
23 |
24 |
25 | mysql
26 | mysql-connector-java
27 |
28 |
29 |
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-maven-plugin
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/spring-boot-jpa/src/main/java/com/ikeguang/jpa/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jpa;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/5 14:04
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 |
13 | @SpringBootApplication
14 | public class Application {
15 | public static void main(String[] args) {
16 | SpringApplication.run(Application.class, args);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/spring-boot-jpa/src/main/java/com/ikeguang/jpa/repository/UserMutiRepository.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jpa.repository;
2 |
3 | import com.ikeguang.jpa.model.User;
4 | import org.springframework.data.domain.Page;
5 | import org.springframework.data.domain.Pageable;
6 | import org.springframework.data.jpa.repository.JpaRepository;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/5 16:47
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | public interface UserMutiRepository extends JpaRepository{
15 |
16 | @Override
17 | Page findAll(Pageable pageable);
18 |
19 | Page findByUserName(String userName, Pageable pageable);
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/spring-boot-jpa/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/spring-boot-jpa/src/main/resources/application.properties
--------------------------------------------------------------------------------
/spring-boot-jpa/src/test/java/com/ikeguang/jpa/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.jpa;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/5 14:23
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @RunWith(SpringRunner.class)
15 | @SpringBootTest
16 | public class ApplicationTest {
17 |
18 | @Test
19 | public void contextLoads(){
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-boot-mail/src/main/java/com/ikeguang/mail/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.mail;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/8 10:38
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 | @SpringBootApplication
13 | public class Application {
14 | public static void main(String[] args) {
15 | SpringApplication.run(Application.class, args);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/spring-boot-mail/src/main/java/com/ikeguang/mail/service/MailService.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.mail.service;
2 |
3 | /**
4 | * @ Author: keguang
5 | * @ Date: 2019/7/8 10:07
6 | * @ version: v1.0.0
7 | * @ description:
8 | */
9 | public interface MailService {
10 |
11 | public void sendMail(String to, String subject, String content);
12 |
13 | public void sendHtmlMail(String to, String subject, String content);
14 |
15 | public void sendAttachmentsMail(String to, String subject, String content, String filePath);
16 |
17 | public void sendInlineResourceMail(String to, String subject, String content, String rscPath, String rscId);
18 | }
19 |
--------------------------------------------------------------------------------
/spring-boot-mail/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # 邮箱服务器地址
2 | spring.mail.host=smtp.126.com
3 |
4 | # 用户名
5 | spring.mail.username=ikeguang@126.com
6 |
7 | # 密码
8 | spring.mail.password=******
9 | spring.mail.default-encoding=UTF-8
10 |
11 | # 以谁来发送邮件
12 | mail.fromMail.addr=ikeguang@126.com
13 |
--------------------------------------------------------------------------------
/spring-boot-mail/src/main/resources/templates/emailTemplate.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Title
6 |
7 |
8 | 您好,这是验证邮件,请点击下面的链接完成验证,
9 | 激活账号
10 |
11 |
--------------------------------------------------------------------------------
/spring-boot-mail/src/test/java/com/ikeguang/mail/ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.mail;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/8 10:37
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @RunWith(SpringRunner.class)
15 | @SpringBootTest
16 | public class ApplicationTests {
17 |
18 | @Test
19 | public void contextLoads(){
20 | System.out.println("hello world");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-boot-monitor-mysql/monitor_table.sql:
--------------------------------------------------------------------------------
1 | /*
2 | Navicat MySQL Data Transfer
3 |
4 | Source Server : local
5 | Source Server Version : 50726
6 | Source Host : localhost:3306
7 | Source Database : test
8 |
9 | Target Server Type : MYSQL
10 | Target Server Version : 50726
11 | File Encoding : 65001
12 |
13 | Date: 2019-07-26 11:53:40
14 | */
15 |
16 | SET FOREIGN_KEY_CHECKS=0;
17 |
18 | -- ----------------------------
19 | -- Table structure for `monitor_table`
20 | -- ----------------------------
21 | DROP TABLE IF EXISTS `monitor_table`;
22 | CREATE TABLE `monitor_table` (
23 | `id` bigint(20) NOT NULL AUTO_INCREMENT,
24 | `table_name` varchar(255) NOT NULL DEFAULT '' COMMENT '表名',
25 | `date_column_name` varchar(255) NOT NULL COMMENT '日期列的列名',
26 | `status` varchar(255) NOT NULL DEFAULT '' COMMENT '是否启用',
27 | `realtime` varchar(255) NOT NULL DEFAULT '' COMMENT '是实时还是离线',
28 | `hour_column_name` varchar(255) DEFAULT '' COMMENT '如果是实时的话保存小时的列名',
29 | PRIMARY KEY (`id`),
30 | UNIQUE KEY `UK_33qgy7n8hu0us8ik8k7nu77sy` (`table_name`)
31 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
32 |
33 | -- ----------------------------
34 | -- Records of monitor_table
35 | -- ----------------------------
--------------------------------------------------------------------------------
/spring-boot-monitor-mysql/src/main/java/com/ikeguang/monitor/mysql/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.monitor.mysql;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.scheduling.annotation.EnableScheduling;
6 |
7 | /**
8 | * @ Author: keguang
9 | * @ Date: 2019/7/25 10:42
10 | * @ version: v1.0.0
11 | * @ description:
12 | */
13 | @SpringBootApplication
14 | @EnableScheduling
15 | public class Application {
16 |
17 | public static void main(String[] args) {
18 | SpringApplication.run(Application.class, args);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-monitor-mysql/src/main/java/com/ikeguang/monitor/mysql/config/MysqlConfig.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.monitor.mysql.config;
2 |
3 | import org.hibernate.dialect.MySQL5Dialect;
4 | import org.springframework.stereotype.Component;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/16 9:58
9 | * @ version: v1.0.0
10 | * @ description: 解决hibernate自动建表字符集为latin不能插入中文的问题。
11 | */
12 | @Component
13 | @SuppressWarnings("deprecation")
14 | public class MysqlConfig extends MySQL5Dialect{
15 |
16 | @Override
17 | public String getTableTypeString() {
18 | return "ENGINE=InnoDB DEFAULT CHARSET=utf8";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-monitor-mysql/src/main/java/com/ikeguang/monitor/mysql/repository/MonitorTableRepository.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.monitor.mysql.repository;
2 |
3 | import com.ikeguang.monitor.mysql.model.MonitorTable;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/25 11:10
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | public interface MonitorTableRepository extends JpaRepository {
15 |
16 | /**
17 | * 根据表名查询
18 | * @param tableName
19 | * @return MonitorTable对象
20 | */
21 | MonitorTable findByTableName(String tableName);
22 |
23 | /**
24 | * 根据是否启用状态查询
25 | * @param status 该监控是否启用
26 | * @return
27 | */
28 | List findByStatus(String status);
29 |
30 | List findByStatusAndRealtime(String status, String realtime);
31 | }
32 |
--------------------------------------------------------------------------------
/spring-boot-monitor-mysql/src/main/java/com/ikeguang/monitor/mysql/service/MailService.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.monitor.mysql.service;
2 |
3 | /**
4 | * @ Author: keguang
5 | * @ Date: 2019/7/8 10:07
6 | * @ version: v1.0.0
7 | * @ description:
8 | */
9 | public interface MailService {
10 |
11 | public void sendMail(String to, String subject, String content);
12 |
13 | public void sendHtmlMail(String to, String subject, String content);
14 |
15 | public void sendAttachmentsMail(String to, String subject, String content, String filePath);
16 |
17 | public void sendInlineResourceMail(String to, String subject, String content, String rscPath, String rscId);
18 | }
19 |
--------------------------------------------------------------------------------
/spring-boot-monitor-mysql/src/main/java/com/ikeguang/monitor/mysql/service/MonitorTableService.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.monitor.mysql.service;
2 |
3 | import com.ikeguang.monitor.mysql.model.MonitorTable;
4 | import org.springframework.data.domain.Page;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/25 11:20
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | public interface MonitorTableService {
15 |
16 | Page getMonitorTableList(int pageNum, int pageSize);
17 |
18 | List findByStatusAndRealtime(String status, String realtime);
19 |
20 | MonitorTable findMonitorTableById(Long id);
21 |
22 | MonitorTable findByTableName(String tableName);
23 |
24 | void edit(MonitorTable monitorTable);
25 |
26 | void save(MonitorTable monitorTable);
27 |
28 | void deleteById(long id);
29 | }
30 |
--------------------------------------------------------------------------------
/spring-boot-monitor-mysql/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=true
2 | spring.datasource.username=root
3 | spring.datasource.password=root
4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
5 |
6 | spring.jpa.properties.hibernate.hbm2ddl.auto=update
7 | spring.jpa.properties.hibernate.dialect=com.ikeguang.monitor.mysql.config.MysqlConfig
8 | spring.jpa.show-sql= true
9 |
10 | spring.thymeleaf.cache=false
11 |
12 | # 邮箱服务器地址
13 | spring.mail.host=smtp.exmail.qq.com
14 |
15 | # 用户名
16 | spring.mail.username=******
17 | # 密码
18 | spring.mail.password=******
19 |
20 | spring.mail.default-encoding=UTF-8
21 |
22 | # 以谁来发送邮件
23 | mail.fromMail.addr=******
24 |
25 | # 端口
26 | server.port=80
27 |
--------------------------------------------------------------------------------
/spring-boot-monitor-mysql/src/test/java/com/ikeguang/monitor/mysql/ApplocationTest.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.monitor.mysql;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/25 10:45
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @RunWith(SpringRunner.class)
15 | @SpringBootTest
16 | public class ApplocationTest {
17 |
18 | @Test
19 | public void loadContext(){
20 | System.out.println("com.ikeguang.monitor.mysql");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-boot-monitor-mysql/src/test/java/com/ikeguang/monitor/mysql/util/DateUtilTests.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.monitor.mysql.util;
2 |
3 | import org.junit.Test;
4 |
5 | /**
6 | * @ Author: keguang
7 | * @ Date: 2019/7/26 16:51
8 | * @ version: v1.0.0
9 | * @ description:
10 | */
11 | public class DateUtilTests {
12 |
13 | @Test
14 | public void test(){
15 | String dateHour = DateUtils.getDayHour(0, 0);
16 | System.out.println(dateHour);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/spring-boot-mybatis/src/main/java/com/ikeguang/mybatis/annotation/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.mybatis.annotation;
2 |
3 | import org.mybatis.spring.annotation.MapperScan;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 |
7 | /**
8 | * @ Author: keguang
9 | * @ Date: 2019/6/28 9:31
10 | * @ version: v1.0.0
11 | * @ description:
12 | */
13 |
14 | @SpringBootApplication
15 | @MapperScan("com.ikeguang.mybatis.annotation.mapper")
16 | public class Application {
17 |
18 | public static void main(String[] args) {
19 | SpringApplication.run(Application.class, args);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/spring-boot-mybatis/src/main/java/com/ikeguang/mybatis/annotation/enums/UserSexEnum.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.mybatis.annotation.enums;
2 |
3 | /**
4 | * @ Author: keguang
5 | * @ Date: 2019/7/1 16:43
6 | * @ version: v1.0.0
7 | * @ description:
8 | */
9 | public enum UserSexEnum {
10 | MAN,WOMAN
11 | }
12 |
--------------------------------------------------------------------------------
/spring-boot-mybatis/src/main/java/com/ikeguang/mybatis/annotation/mapper/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.mybatis.annotation.mapper;
2 |
3 | import com.ikeguang.mybatis.annotation.enums.UserSexEnum;
4 | import com.ikeguang.mybatis.annotation.model.User;
5 | import org.apache.ibatis.annotations.*;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * @ Author: keguang
11 | * @ Date: 2019/7/1 16:59
12 | * @ version: v1.0.0
13 | * @ description:
14 | */
15 | public interface UserMapper {
16 |
17 | @Select("SELECT * FROM users")
18 | @Results({
19 | @Result(property = "userSex", column = "user_sex", javaType = UserSexEnum.class),
20 | @Result(property = "nickName", column = "nick_name")
21 | })
22 | List getAll();
23 |
24 | @Select("SELECT * FROM users WHERE id = #{id}")
25 | @Results({
26 | @Result(property = "userSex", column = "user_sex", javaType = UserSexEnum.class),
27 | @Result(property = "nickName", column = "nick_name")
28 | })
29 | User getOne(Long id);
30 |
31 | @Insert("INSERT INTO users(userName,passWord,user_sex) VALUES(#{userName}, #{passWord}, #{userSex})")
32 | void insert(User user);
33 |
34 | @Update("UPDATE users SET userName=#{userName},nick_name=#{nickName} WHERE id =#{id}")
35 | void update(User user);
36 |
37 | @Delete("DELETE FROM users WHERE id =#{id}")
38 | void delete(Long id);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/spring-boot-mybatis/src/main/java/com/ikeguang/mybatis/annotation/sql.sql:
--------------------------------------------------------------------------------
1 | DROP TABLE IF EXISTS `users`;
2 | CREATE TABLE `users` (
3 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
4 | `userName` varchar(32) DEFAULT NULL COMMENT '用户名',
5 | `passWord` varchar(32) DEFAULT NULL COMMENT '密码',
6 | `user_sex` varchar(32) DEFAULT NULL,
7 | `nick_name` varchar(32) DEFAULT NULL,
8 | PRIMARY KEY (`id`)
9 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
10 |
11 |
12 | -- insert into `users`(userName, passWord, user_sex, nick_name) VALUES ('keguang', '123456', '')
--------------------------------------------------------------------------------
/spring-boot-mybatis/src/main/java/com/ikeguang/mybatis/annotation/web/UserController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.mybatis.annotation.web;
2 |
3 | import com.ikeguang.mybatis.annotation.mapper.UserMapper;
4 | import com.ikeguang.mybatis.annotation.model.User;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.web.bind.annotation.PathVariable;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * @ Author: keguang
14 | * @ Date: 2019/7/1 17:17
15 | * @ version: v1.0.0
16 | * @ description:
17 | */
18 |
19 | @RestController
20 | public class UserController {
21 |
22 | @Autowired
23 | private UserMapper userMapper;
24 |
25 | @RequestMapping("/getUsers")
26 | public List getUsers() {
27 | List users=userMapper.getAll();
28 | return users;
29 | }
30 |
31 | @RequestMapping("/getUser")
32 | public User getUser(Long id) {
33 | User user=userMapper.getOne(id);
34 | return user;
35 | }
36 |
37 | @RequestMapping("/add")
38 | public void save(User user) {
39 | userMapper.insert(user);
40 | }
41 |
42 | @RequestMapping(value="update")
43 | public void update(User user) {
44 | userMapper.update(user);
45 | }
46 |
47 | @RequestMapping(value="/delete/{id}")
48 | public void delete(@PathVariable("id") Long id) {
49 | userMapper.delete(id);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/spring-boot-mybatis/src/main/java/com/ikeguang/mybatis/xml/XMLApplication.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.mybatis.xml;
2 |
3 | import org.mybatis.spring.annotation.MapperScan;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 |
7 | /**
8 | * @ Author: keguang
9 | * @ Date: 2019/7/5 10:10
10 | * @ version: v1.0.0
11 | * @ description:
12 | */
13 | @SpringBootApplication
14 | @MapperScan("com.ikeguang.mybatis.xml.mapper")
15 | public class XMLApplication {
16 | public static void main(String[] args) {
17 | SpringApplication.run(XMLApplication.class);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/spring-boot-mybatis/src/main/java/com/ikeguang/mybatis/xml/mapper/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.mybatis.xml.mapper;
2 |
3 | import com.ikeguang.mybatis.xml.model.User;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * @ Author: keguang
9 | * @ Date: 2019/7/5 9:53
10 | * @ version: v1.0.0
11 | * @ description:
12 | */
13 | public interface UserMapper {
14 |
15 | List getAll();
16 |
17 | User getOne(Long id);
18 |
19 | void insert(User user);
20 |
21 | void update(User user);
22 |
23 | void delete(Long id);
24 | }
25 |
--------------------------------------------------------------------------------
/spring-boot-mybatis/src/main/java/com/ikeguang/mybatis/xml/web/UserController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.mybatis.xml.web;
2 |
3 | import com.ikeguang.mybatis.xml.mapper.UserMapper;
4 | import com.ikeguang.mybatis.xml.model.User;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.web.bind.annotation.PathVariable;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * @ Author: keguang
14 | * @ Date: 2019/7/5 10:56
15 | * @ version: v1.0.0
16 | * @ description:
17 | */
18 |
19 | @RestController
20 | public class UserController {
21 |
22 | @Autowired
23 | private UserMapper userMapper;
24 |
25 | @RequestMapping("/xml/getUsers")
26 | public List getUsers() {
27 | List users=userMapper.getAll();
28 | return users;
29 | }
30 |
31 | @RequestMapping("/xml/getUser/{id}")
32 | public User getUser(@PathVariable("id") Long id) {
33 | User user=userMapper.getOne(id);
34 | return user;
35 | }
36 |
37 | @RequestMapping("/xml/add")
38 | public void save(User user) {
39 | userMapper.insert(user);
40 | }
41 |
42 | @RequestMapping(value="/xml/update")
43 | public void update(User user) {
44 | userMapper.update(user);
45 | }
46 |
47 | @RequestMapping(value="/xml/delete/{id}")
48 | public void delete(@PathVariable("id") Long id) {
49 | userMapper.delete(id);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/spring-boot-mybatis/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | mybatis.type-aliases-package=com.ikeguang.mybatis.annotation.model
2 | mybatis.config-location=classpath:mybatis/mybatis-config.xml
3 | mybatis.mapper-locations=classpath:mybatis/mapper/*.xml
4 |
5 | spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC&characterEncoding=utf-8&useSSL=true
6 | spring.datasource.username=root
7 | spring.datasource.password=root
8 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
9 |
--------------------------------------------------------------------------------
/spring-boot-mybatis/src/main/resources/mybatis/mybatis-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/spring-boot-mybatis/src/test/java/com/ikeguang/mybatis/xml/MybatisXmlApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.mybatis.xml;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/5 10:05
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 |
15 | @RunWith(SpringRunner.class)
16 | @SpringBootTest
17 | public class MybatisXmlApplicationTests {
18 |
19 | @Test
20 | public void contextLoads(){
21 | System.out.println("hello");
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/spring-boot-mybatis/src/test/java/com/ikeguang/mybatis/xml/web/UserControllerTest.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.mybatis.xml.web;
2 |
3 | import org.junit.Before;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.context.SpringBootTest;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.test.context.junit4.SpringRunner;
10 | import org.springframework.test.web.servlet.MockMvc;
11 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
12 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
13 | import org.springframework.web.context.WebApplicationContext;
14 |
15 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
16 | /**
17 | * @ Author: keguang
18 | * @ Date: 2019/7/5 11:13
19 | * @ version: v1.0.0
20 | * @ description:
21 | */
22 | @RunWith(SpringRunner.class)
23 | @SpringBootTest
24 | public class UserControllerTest {
25 |
26 | @Autowired
27 | private WebApplicationContext wac;
28 | private MockMvc mockMvc;
29 |
30 | @Before
31 | public void setUp() throws Exception {
32 | mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); //初始化MockMvc对象
33 | }
34 |
35 | @Test
36 | public void getUsers() throws Exception {
37 | mockMvc.perform(MockMvcRequestBuilders.post("/xml/getUsers")
38 | .accept(MediaType.APPLICATION_JSON_UTF8)).andDo(print());
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/spring-boot-oath/src/main/java/com/ikeguang/oath/OathApplication.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.oath;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class OathApplication{
8 | public static void main(String[] args) {
9 | SpringApplication.run(OathApplication.class);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/spring-boot-oath/src/main/java/com/ikeguang/oath/controller/IndexController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.oath.controller;
2 |
3 | import com.ikeguang.oath.model.GitHubAccessModel;
4 | import com.ikeguang.oath.util.GitHubProvider;
5 | import lombok.extern.slf4j.Slf4j;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Controller;
8 | import org.springframework.web.bind.annotation.*;
9 |
10 | @Controller
11 | @RequestMapping("/oauth")
12 | @Slf4j
13 | public class IndexController {
14 |
15 | // @Autowired
16 | GitHubAccessModel gitHubAccessModel = new GitHubAccessModel();
17 |
18 | @Autowired
19 | private GitHubProvider gitHubProvider;
20 |
21 | @RequestMapping({"/", "index"})
22 | public String index(){
23 | return "index";
24 | }
25 |
26 | @GetMapping("/callback/{source}")
27 | @ResponseBody
28 | public String callback(@PathVariable(name = "source") String source,
29 | @RequestParam(name="code") String code,
30 | @RequestParam(name = "state") String state){
31 | log.info("source -> {}, code -> {}, state -> {}", source, code, state);
32 | gitHubAccessModel.setCode(code);
33 | gitHubAccessModel.setState(state);
34 | //进行doPost请求,获取access_token
35 | gitHubProvider.getAccessToken(gitHubAccessModel);
36 | return "finish";
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/spring-boot-oath/src/main/java/com/ikeguang/oath/model/GitHubAccessModel.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.oath.model;
2 |
3 | import lombok.Data;
4 | import lombok.ToString;
5 | import org.springframework.beans.factory.annotation.Value;
6 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
7 | import org.springframework.boot.context.properties.ConfigurationProperties;
8 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
9 | import org.springframework.context.annotation.ComponentScan;
10 | import org.springframework.context.annotation.Configuration;
11 | import org.springframework.stereotype.Component;
12 |
13 | @Data
14 | @ToString
15 | // @Configuration
16 | public class GitHubAccessModel {
17 | //@Value("${oauth.github.clientId}")
18 | private String clientId = "6f286cb0adc5c19659aa";
19 |
20 | //@Value("${oauth.github.clientSecret}")
21 | private String clientSecret = "0cb56d595b37d96e2dd7480c98b5d153a74c8088";
22 |
23 | private String code;
24 |
25 | //@Value("${oauth.github.redirectUri}")
26 | private String redirectUri = "http://localhost:8080/oauth/callback/github";
27 |
28 | private String state;
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/spring-boot-oath/src/main/java/com/ikeguang/oath/model/GithubUserModel.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.oath.model;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public class GithubUserModel {
7 | private String name;
8 | private Long id;
9 | private String bio;
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/spring-boot-oath/src/main/java/com/ikeguang/oath/util/GitHubProvider.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.oath.util;
2 |
3 | import com.alibaba.fastjson.JSON;
4 | import com.ikeguang.oath.model.GitHubAccessModel;
5 | import lombok.extern.slf4j.Slf4j;
6 | import okhttp3.*;
7 | import org.springframework.stereotype.Component;
8 |
9 | import java.io.IOException;
10 |
11 | @Component
12 | @Slf4j
13 | public class GitHubProvider {
14 | public String getAccessToken(GitHubAccessModel gitHubAccessModel){
15 | log.info(gitHubAccessModel.toString());
16 | MediaType mediaType= MediaType.get("application/json; charset=utf-8");
17 | OkHttpClient client = new OkHttpClient();
18 | RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(gitHubAccessModel));
19 | Request request = new Request.Builder()
20 | .url("https://github.com/login/oauth/access_token")
21 | .post(body)
22 | .build();
23 | try (Response response = client.newCall(request).execute()) {
24 | String string = response.body().string();
25 | System.out.println(response.isSuccessful());
26 | System.out.println(string);
27 | return string;
28 | } catch (IOException e) {
29 | }
30 | return null;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/spring-boot-oath/src/main/resources/application-test.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8080
3 | oauth:
4 | github:
5 | clientId: 6f286cb0adc5c19659aa
6 | clientSecret: 0cb56d595b37d96e2dd7480c98b5d153a74c8088
7 | redirectUri: http://localhost:8080/oauth/callback/github
--------------------------------------------------------------------------------
/spring-boot-oath/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | profiles:
3 | active: test
--------------------------------------------------------------------------------
/spring-boot-oath/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 第三方登录测试
6 |
7 |
8 | 登录
9 |
10 |
--------------------------------------------------------------------------------
/spring-boot-oath/src/test/java/com/ikeguang/oath/OkhttpTests.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.oath;
2 |
3 | import com.alibaba.fastjson.JSON;
4 | import com.ikeguang.oath.model.GitHubAccessModel;
5 | import okhttp3.*;
6 | import org.junit.Test;
7 |
8 | public class OkhttpTests {
9 |
10 | @Test
11 | public void test(){
12 | GitHubAccessModel gitHubAccessModel = new GitHubAccessModel();
13 | gitHubAccessModel.setCode("67ca05779b19c01b9610");
14 | gitHubAccessModel.setState("1");
15 | MediaType mediaType = MediaType.get("application/json; charset=utf-8");
16 | OkHttpClient client = new OkHttpClient();
17 | RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(gitHubAccessModel));
18 | System.out.println(gitHubAccessModel);
19 | Request request = new Request.Builder()
20 | .url("https://github.com/login/oauth/access_token")
21 | .post(body)
22 | .build();
23 | try (Response response = client.newCall(request).execute()) {
24 | System.out.println(response.isSuccessful());
25 | System.out.println(response.code());
26 | String string = response.body().string();
27 | System.out.println(string);
28 | String token = string.split("&")[0].split("=")[1];
29 | System.out.println(token);
30 | } catch (Exception e) {
31 | e.printStackTrace();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/spring-boot-oath/src/test/java/com/ikeguang/oath/model/GitHubAccessModelTests.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.oath.model;
2 |
3 | import com.alibaba.fastjson.JSON;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.context.SpringBootTest;
8 | import org.springframework.context.annotation.Bean;
9 | import org.springframework.test.context.junit4.SpringRunner;
10 |
11 | import javax.annotation.Resource;
12 |
13 | @SpringBootTest
14 | @RunWith(SpringRunner.class)
15 | public class GitHubAccessModelTests {
16 |
17 | @Autowired
18 | GitHubAccessModel gitHubAccessModel;
19 |
20 | @Test
21 | public void test(){
22 | System.out.println(gitHubAccessModel);
23 | JSON.toJSONString(gitHubAccessModel);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/spring-boot-oauth/src/main/java/org/ikeguang/oauth/OauthApplication.java:
--------------------------------------------------------------------------------
1 | package org.ikeguang.oauth;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * @Author: keguang
8 | * @Date: 2020/10/10 16:26
9 | * @version: v1.0.0
10 | * @description:
11 | */
12 | @SpringBootApplication
13 | public class OauthApplication {
14 |
15 | public static void main(String[] args) {
16 | SpringApplication.run(OauthApplication.class, args);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/spring-boot-paging/src/main/java/com/ikeguang/paging/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.paging;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.builder.SpringApplicationBuilder;
6 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/8 10:38
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @SpringBootApplication
15 | public class Application extends SpringBootServletInitializer{
16 |
17 | @Override
18 | protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
19 | return builder.sources(Application.class);
20 | }
21 |
22 | public static void main(String[] args) {
23 | SpringApplication.run(Application.class, args);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/spring-boot-paging/src/main/java/com/ikeguang/paging/config/MysqlConfig.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.paging.config;
2 |
3 | import org.hibernate.dialect.MySQL5Dialect;
4 | import org.springframework.stereotype.Component;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/16 9:58
9 | * @ version: v1.0.0
10 | * @ description: 解决hibernate自动建表字符集为latin不能插入中文的问题。
11 | */
12 | @Component
13 | @SuppressWarnings("deprecation")
14 | public class MysqlConfig extends MySQL5Dialect{
15 |
16 | @Override
17 | public String getTableTypeString() {
18 | return "ENGINE=InnoDB DEFAULT CHARSET=utf8";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-paging/src/main/java/com/ikeguang/paging/repository/UserRepository.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.paging.repository;
2 |
3 | import com.ikeguang.paging.model.User;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/18 10:23
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 | public interface UserRepository extends JpaRepository{
13 |
14 | User findById(long id);
15 |
16 | void deleteById(long id);
17 | }
18 |
--------------------------------------------------------------------------------
/spring-boot-paging/src/main/java/com/ikeguang/paging/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.paging.service;
2 |
3 | import com.ikeguang.paging.model.User;
4 | import org.springframework.data.domain.Page;
5 |
6 |
7 | /**
8 | * @ Author: keguang
9 | * @ Date: 2019/7/18 10:26
10 | * @ version: v1.0.0
11 | * @ description:
12 | */
13 | public interface UserService {
14 |
15 | Page getUserList(int pageNum, int pageSize);
16 |
17 | User findUserById(long id);
18 |
19 | void save(User user);
20 |
21 | void edit(User user);
22 |
23 | void delete(long id);
24 | }
25 |
--------------------------------------------------------------------------------
/spring-boot-paging/src/main/java/com/ikeguang/paging/web/HelloController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.paging.web;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.ui.Model;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RequestParam;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/18 10:29
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @Controller
15 | public class HelloController {
16 |
17 | @RequestMapping("/hello")
18 | public String hello(Model model, @RequestParam(value = "name", required = false, defaultValue = "world") String name){
19 | model.addAttribute("name", name);
20 |
21 | return "hello";
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/spring-boot-paging/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=true
2 | spring.datasource.username=root
3 | spring.datasource.password=root
4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
5 |
6 | spring.jpa.properties.hibernate.hbm2ddl.auto=update
7 | spring.jpa.properties.hibernate.dialect=com.ikeguang.paging.config.MysqlConfig
8 | spring.jpa.show-sql= true
9 |
10 | spring.thymeleaf.cache=false
11 |
12 | # 配置分页
13 | # pagehelper.helper-dialect=mysql
14 | # pagehelper.reasonable=true
15 | # pagehelper.support-methods-arguments=true
16 | # pagehelper.params=count=countSql
--------------------------------------------------------------------------------
/spring-boot-paging/src/main/resources/templates/hello.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Hello Thymeleaf!
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/spring-boot-redis/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-learn
7 | com.ikeguang
8 | 1.0.0
9 |
10 | 4.0.0
11 |
12 | spring-boot-redis
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-starter-test
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-data-redis
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/spring-boot-redis/src/main/java/com/ikeguang/redis/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.redis;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Application {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(Application.class, args);
11 | }
12 |
13 | }
--------------------------------------------------------------------------------
/spring-boot-redis/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # REDIS (RedisProperties)
2 | # Redis数据库索引(默认为0)
3 | spring.redis.database=0
4 | # Redis服务器地址
5 | spring.redis.host=localhost
6 | # Redis服务器连接端口
7 | spring.redis.port=6379
8 | # Redis服务器连接密码(默认为空)
9 | spring.redis.password=123456
10 | # 连接池最大连接数(使用负值表示没有限制)
11 | spring.redis.pool.max-active=8
12 | # 连接池最大阻塞等待时间(使用负值表示没有限制)
13 | spring.redis.pool.max-wait=-1
14 | # 连接池中的最大空闲连接
15 | spring.redis.pool.max-idle=8
16 | # 连接池中的最小空闲连接
17 | spring.redis.pool.min-idle=0
18 | # 连接超时时间(毫秒)
19 | spring.redis.timeout=1000
20 |
--------------------------------------------------------------------------------
/spring-boot-redis/src/test/java/com/ikeguang/redis/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.redis;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.context.SpringBootTest;
8 | import org.springframework.data.redis.core.StringRedisTemplate;
9 | import org.springframework.test.context.junit4.SpringRunner;
10 |
11 | /**
12 | * @ Author: keguang
13 | * @ Date: 2019/8/12 15:59
14 | * @ version: v1.0.0
15 | * @ description:
16 | */
17 | @RunWith(SpringRunner.class)
18 | @SpringBootTest
19 | public class ApplicationTest {
20 |
21 | @Autowired
22 | private StringRedisTemplate stringRedisTemplate;
23 |
24 | @Test
25 | public void test(){
26 | stringRedisTemplate.opsForValue().set("name", "keguang");
27 | Assert.assertEquals("keguang", stringRedisTemplate.opsForValue().get("name"));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/spring-boot-security/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-learn
7 | com.ikeguang
8 | 1.0.0
9 |
10 | 4.0.0
11 |
12 | spring-boot-security
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-starter-web
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-thymeleaf
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-test
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-security
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/spring-boot-security/src/main/java/com/ikeguang/security/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.security;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/6/28 9:31
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 | @SpringBootApplication
13 | public class Application {
14 |
15 | public static void main(String[] args) {
16 | SpringApplication.run(Application.class, args);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/spring-boot-security/src/main/java/com/ikeguang/security/web/HelloController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.security.web;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/8/20 15:24
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 | @Controller
13 | public class HelloController {
14 |
15 | @RequestMapping("/")
16 | public String index(){
17 | return "index";
18 | }
19 |
20 | @RequestMapping("/hello")
21 | public String hello(){
22 | return "hello";
23 | }
24 |
25 | @RequestMapping("/login")
26 | public String login(){
27 | return "login";
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/spring-boot-security/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/spring-boot-security/src/main/resources/application.properties
--------------------------------------------------------------------------------
/spring-boot-security/src/main/resources/templates/hello.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | Hello World!
6 |
7 |
8 | Hello [[${#httpServletRequest.remoteUser}]]!
9 |
12 |
13 |
--------------------------------------------------------------------------------
/spring-boot-security/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Spring Security入门
5 |
6 |
7 | 欢迎使用Spring Security!
8 | 点击 这里 打个招呼吧
9 |
10 |
--------------------------------------------------------------------------------
/spring-boot-security/src/main/resources/templates/login.html:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | Spring Security Example
7 |
8 |
9 |
10 | 用户名或密码错
11 |
12 |
13 | 您已注销成功
14 |
15 |
20 |
21 |
--------------------------------------------------------------------------------
/spring-boot-security/src/test/java/com/ikeguang/security/ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.security;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/8/20 15:30
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @RunWith(SpringRunner.class)
15 | @SpringBootTest
16 | public class ApplicationTests {
17 |
18 | @Test
19 | public void loadContext(){
20 | System.out.println("ApplicationTests .");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/java/com/ikeguang/shiro/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.shiro;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/8 10:38
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 | @SpringBootApplication
13 | public class Application {
14 | public static void main(String[] args) {
15 | SpringApplication.run(Application.class, args);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/java/com/ikeguang/shiro/config/MysqlConfig.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.shiro.config;
2 |
3 | import org.hibernate.dialect.MySQL5Dialect;
4 | import org.springframework.stereotype.Component;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/16 9:58
9 | * @ version: v1.0.0
10 | * @ description: 解决hibernate自动建表字符集为latin不能插入中文的问题。
11 | */
12 | @Component
13 | @SuppressWarnings("deprecation")
14 | public class MysqlConfig extends MySQL5Dialect{
15 |
16 | @Override
17 | public String getTableTypeString() {
18 | return "ENGINE=InnoDB DEFAULT CHARSET=utf8";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/java/com/ikeguang/shiro/dao/UserInfoDao.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.shiro.dao;
2 |
3 | import com.ikeguang.shiro.model.UserInfo;
4 | import org.springframework.data.repository.CrudRepository;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/15 16:37
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 | public interface UserInfoDao extends CrudRepository{
13 |
14 | /**通过username查找用户信息;*/
15 | public UserInfo findByUsername(String username);
16 | }
17 |
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/java/com/ikeguang/shiro/service/UserInfoService.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.shiro.service;
2 |
3 | import com.ikeguang.shiro.model.UserInfo;
4 |
5 | /**
6 | * @ Author: keguang
7 | * @ Date: 2019/7/15 16:43
8 | * @ version: v1.0.0
9 | * @ description:
10 | */
11 | public interface UserInfoService {
12 |
13 | /**通过username查找用户信息;*/
14 | public UserInfo findByUsername(String username);
15 | }
16 |
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/java/com/ikeguang/shiro/service/impl/UserInfoServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.shiro.service.impl;
2 |
3 | import com.ikeguang.shiro.dao.UserInfoDao;
4 | import com.ikeguang.shiro.model.UserInfo;
5 | import com.ikeguang.shiro.service.UserInfoService;
6 | import org.springframework.stereotype.Service;
7 |
8 | import javax.annotation.Resource;
9 |
10 | /**
11 | * @ Author: keguang
12 | * @ Date: 2019/7/15 16:44
13 | * @ version: v1.0.0
14 | * @ description:
15 | */
16 | @Service
17 | public class UserInfoServiceImpl implements UserInfoService {
18 | @Resource
19 | private UserInfoDao userInfoDao;
20 | @Override
21 | public UserInfo findByUsername(String username) {
22 | System.out.println("UserInfoServiceImpl.findByUsername()");
23 | return userInfoDao.findByUsername(username);
24 | }
25 | }
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/java/com/ikeguang/shiro/web/UserInfoController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.shiro.web;
2 |
3 | import org.apache.shiro.authz.annotation.RequiresPermissions;
4 | import org.springframework.stereotype.Controller;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 |
7 | /**
8 | * @ Author: keguang
9 | * @ Date: 2019/7/15 17:00
10 | * @ version: v1.0.0
11 | * @ description:
12 | */
13 | @Controller
14 | @RequestMapping("/userInfo")
15 | public class UserInfoController {
16 |
17 | /**
18 | * 用户查询.
19 | * @return
20 | */
21 | @RequestMapping("/userList")
22 | @RequiresPermissions("userInfo:view")
23 | public String userInfo(){
24 | return "userInfo";
25 | }
26 |
27 | @RequestMapping("/userAdd")
28 | @RequiresPermissions("userInfo:add")
29 | public String userInfoAdd(){
30 | return "userInfoAdd";
31 | }
32 |
33 | @RequestMapping("/userDel")
34 | @RequiresPermissions("userInfo:del")
35 | public String userDel(){
36 | return "userInfoDel";
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | datasource:
3 | url: jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true
4 | username: root
5 | password: root
6 | # schema: database/import.sql
7 | #sql-script-encoding: utf-8
8 | driver-class-name: com.mysql.cj.jdbc.Driver
9 |
10 | jpa:
11 | database: mysql
12 | show-sql: true
13 | hibernate:
14 | ddl-auto: update
15 | properties:
16 | hibernate:
17 | # dialect: org.hibernate.dialect.MySQL5Dialect
18 | dialect: com.ikeguang.shiro.config.MysqlConfig
19 |
20 | thymeleaf:
21 | cache: false
22 | mode: HTML
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/resources/database/import.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO `user_info` (`uid`,`username`,`name`,`password`,`salt`,`state`) VALUES ('1', 'admin', '管理员', 'd3c59d25033dbf980d29554025c23a75', '8d78869f470951332959580424d4bf4f', 0);
2 | INSERT INTO `sys_permission` (`id`,`available`,`name`,`parent_id`,`parent_ids`,`permission`,`resource_type`,`url`) VALUES (1,0,'用户管理',0,'0/','userInfo:view','menu','userInfo/user2List');
3 | INSERT INTO `sys_permission` (`id`,`available`,`name`,`parent_id`,`parent_ids`,`permission`,`resource_type`,`url`) VALUES (2,0,'用户添加',1,'0/1','userInfo:add','button','userInfo/userAdd');
4 | INSERT INTO `sys_permission` (`id`,`available`,`name`,`parent_id`,`parent_ids`,`permission`,`resource_type`,`url`) VALUES (3,0,'用户删除',1,'0/1','userInfo:del','button','userInfo/userDel');
5 | INSERT INTO `sys_role` (`id`,`available`,`description`,`role`) VALUES (1,0,'管理员','admin');
6 | INSERT INTO `sys_role` (`id`,`available`,`description`,`role`) VALUES (2,0,'VIP会员','vip');
7 | INSERT INTO `sys_role` (`id`,`available`,`description`,`role`) VALUES (3,1,'test','test');
8 | INSERT INTO `sys_role_permission` VALUES ('1', '1');
9 | INSERT INTO `sys_role_permission` (`permission_id`,`role_id`) VALUES (1,1);
10 | INSERT INTO `sys_role_permission` (`permission_id`,`role_id`) VALUES (2,1);
11 | INSERT INTO `sys_role_permission` (`permission_id`,`role_id`) VALUES (3,2);
12 | INSERT INTO `sys_user_role` (`role_id`,`uid`) VALUES (1,1);
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/resources/templates/403.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 403
6 |
7 |
8 | 403没有权限
9 |
10 |
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | index
6 |
7 |
8 | index
9 |
10 |
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/resources/templates/login.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Login
6 |
7 |
8 | 错误信息:
9 |
14 |
15 |
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/resources/templates/userInfo.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UserInfo
6 |
7 |
8 | 用户查询界面
9 |
10 |
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/resources/templates/userInfoAdd.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Add
6 |
7 |
8 | 用户添加界面
9 |
10 |
--------------------------------------------------------------------------------
/spring-boot-shiro/src/main/resources/templates/userInfoDel.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Del
6 |
7 |
8 | 用户删除界面
9 |
10 |
--------------------------------------------------------------------------------
/spring-boot-shiro/src/test/java/com/ikeguang/shiro/ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.shiro;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/15 17:38
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @RunWith(SpringRunner.class)
15 | @SpringBootTest
16 | public class ApplicationTests {
17 |
18 | @Test
19 | public void contextLoads(){
20 | System.out.println("contextLoads...");
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/spring-boot-swagger2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-learn
7 | com.ikeguang
8 | 1.0.0
9 |
10 | 4.0.0
11 |
12 | spring-boot-swagger2
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-starter-web
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-test
26 |
27 |
28 | io.springfox
29 | springfox-swagger2
30 | 2.2.2
31 |
32 |
33 | io.springfox
34 | springfox-swagger-ui
35 | 2.2.2
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/spring-boot-swagger2/src/main/java/com/ikeguang/swagger2/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.swagger2;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * @Author: keguang
8 | * @Date: 2019/7/8 10:38
9 | * @version: v1.0.0
10 | * @description: Spring Boot构建RESTful API与单元测试
11 | */
12 | @SpringBootApplication
13 | public class Application {
14 | public static void main(String[] args) {
15 | SpringApplication.run(Application.class, args);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/spring-boot-swagger2/src/main/java/com/ikeguang/swagger2/Swagger2.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.swagger2;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import springfox.documentation.builders.ApiInfoBuilder;
6 | import springfox.documentation.builders.PathSelectors;
7 | import springfox.documentation.builders.RequestHandlerSelectors;
8 | import springfox.documentation.service.ApiInfo;
9 | import springfox.documentation.spi.DocumentationType;
10 | import springfox.documentation.spring.web.plugins.Docket;
11 | import springfox.documentation.swagger2.annotations.EnableSwagger2;
12 |
13 | /**
14 | * @Author: keguang
15 | * @Date: 2019/7/30 17:33
16 | * @version: v1.0.0
17 | * @description:
18 | */
19 | @Configuration
20 | @EnableSwagger2
21 | public class Swagger2 {
22 |
23 | @Bean
24 | public Docket createRestApi(){
25 | return new Docket(DocumentationType.SWAGGER_2)
26 | .apiInfo(apiInfo())
27 | .select()
28 | .apis(RequestHandlerSelectors.basePackage(""))
29 | .paths(PathSelectors.any())
30 | .build();
31 | }
32 |
33 | private ApiInfo apiInfo(){
34 | return new ApiInfoBuilder()
35 | .title("Spring Boot中使用Swagger2构建RESTful APIs")
36 | .description("ikeguang")
37 | .termsOfServiceUrl("ikeguang.com")
38 | .contact("重橙")
39 | .version("1.0")
40 | .build();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/spring-boot-swagger2/src/main/java/com/ikeguang/swagger2/model/User.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.swagger2.model;
2 |
3 | import io.swagger.annotations.ApiModel;
4 | import io.swagger.annotations.ApiModelProperty;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 | import lombok.ToString;
9 |
10 | /**
11 | * @Author: keguang
12 | * @Date: 2019/7/30 17:39
13 | * @version: v1.0.0
14 | * @description:
15 | */
16 | @NoArgsConstructor
17 | @AllArgsConstructor
18 | @Data
19 | @ToString
20 | @ApiModel(description = "用户实体")
21 | public class User {
22 |
23 | @ApiModelProperty("用户编号")
24 | private Long id;
25 |
26 | @ApiModelProperty("用户姓名")
27 | private String name;
28 |
29 | @ApiModelProperty("用户年龄")
30 | private Integer age;
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/spring-boot-swagger2/src/main/java/com/ikeguang/swagger2/web/HelloController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.swagger2.web;
2 |
3 | import org.springframework.web.bind.annotation.RequestMapping;
4 | import org.springframework.web.bind.annotation.RequestMethod;
5 | import org.springframework.web.bind.annotation.RestController;
6 | import springfox.documentation.annotations.ApiIgnore;
7 |
8 | /**
9 | * @Author: keguang
10 | * @Date: 2019/7/30 17:42
11 | * @version: v1.0.0
12 | * @description:
13 | */
14 |
15 | @RestController
16 | public class HelloController {
17 |
18 | @ApiIgnore
19 | @RequestMapping(value = "/hello", method = RequestMethod.GET)
20 | public String index(){
21 | return "Hello World";
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/java/com/ikeguang/thymeleaf/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.thymeleaf;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/8 10:38
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 | @SpringBootApplication
13 | public class Application {
14 | public static void main(String[] args) {
15 | SpringApplication.run(Application.class, args);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/java/com/ikeguang/thymeleaf/model/User.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.thymeleaf.model;
2 |
3 | /**
4 | * @ Author: keguang
5 | * @ Date: 2019/7/8 13:48
6 | * @ version: v1.0.0
7 | * @ description:
8 | */
9 | public class User {
10 | private String name;
11 | private int age;
12 | private String pass;
13 |
14 | public User(String name, int age, String pass) {
15 | this.name = name;
16 | this.age = age;
17 | this.pass = pass;
18 | }
19 |
20 | public String getName() {
21 | return name;
22 | }
23 |
24 | public void setName(String name) {
25 | this.name = name;
26 | }
27 |
28 | public int getAge() {
29 | return age;
30 | }
31 |
32 | public void setAge(int age) {
33 | this.age = age;
34 | }
35 |
36 | public String getPass() {
37 | return pass;
38 | }
39 |
40 | public void setPass(String pass) {
41 | this.pass = pass;
42 | }
43 |
44 | @Override
45 | public String toString() {
46 | return ("name=" + this.name + ",age=" + this.age + ",pass=" + this.pass);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/java/com/ikeguang/thymeleaf/web/HelloController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.thymeleaf.web;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.ui.ModelMap;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 |
7 | /**
8 | * @ Author: keguang
9 | * @ Date: 2019/7/8 13:50
10 | * @ version: v1.0.0
11 | * @ description:
12 | */
13 | @Controller
14 | public class HelloController {
15 |
16 | @RequestMapping("/")
17 | public String index(ModelMap modelMap){
18 | modelMap.addAttribute("message", "http://www.ikeguang.com/mapsite.xml");
19 | return "hello";
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/java/com/ikeguang/thymeleaf/web/LayoutController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.thymeleaf.web;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/8 15:33
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 | @Controller
13 | public class LayoutController {
14 |
15 | @RequestMapping("/index")
16 | public String index() {
17 | return "index";
18 | }
19 |
20 | @RequestMapping("/fragment")
21 | public String fragment() {
22 | return "fragment";
23 | }
24 |
25 | @RequestMapping("/layout")
26 | public String layout() {
27 | return "layout";
28 | }
29 |
30 | @RequestMapping("/home")
31 | public String home() {
32 | return "home";
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.thymeleaf.cache=false
2 |
3 | com.neo.title=\u7EAF\u6D01\u7684\u5FAE\u7B11
4 | com.neo.description=\u5206\u4EAB\u751F\u6D3B\u548C\u6280\u672F
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | comm title
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/eq.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Example gt eq
6 |
7 |
8 |
9 |
EQ
10 |
11 |
12 |
13 |
14 |
favorites
15 |
16 |
17 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/fragment.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Fragment - Page
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/hello.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Hello
6 |
7 |
8 | Hello World
9 |
10 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/home.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Home
6 |
7 |
8 |
9 |
个性化的内容
10 |
11 |
12 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/if.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Example If/Unless
6 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Index
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Layout
6 |
7 |
8 |
9 |
10 |
11 |
content
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/layout/copyright.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Title
6 |
7 |
8 |
9 | © 2018
10 |
11 |
12 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/layout/footer.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | footer
6 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/layout/header.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | header
6 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/layout/left.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | left
6 |
7 |
8 |
9 | 我是 左侧
10 |
11 |
12 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Example If/Unless
6 |
7 |
8 |
9 |
for 循环
10 |
11 |
12 | neo |
13 | 6 |
14 | 213 |
15 | index |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/string.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Example String
6 |
7 |
8 |
9 |
text
10 |
neo
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/switch.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Example switch
6 |
7 |
8 |
9 |
10 |
她是一个姑娘...
11 |
这是一个爷们!
12 |
13 |
未知性别的一个家伙。
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/main/resources/templates/url.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Example If/Unless
6 |
7 |
8 |
9 |
URL
10 |
link1
11 |
12 |
view
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/spring-boot-thymeleaf/src/test/java/com/ikeguang/thymeleaf/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.thymeleaf;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/8 13:52
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 | @RunWith(SpringRunner.class)
15 | @SpringBootTest
16 | public class ApplicationTest {
17 |
18 | @Test
19 | public void testApplication(){
20 | System.out.println("hello");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * @Author: keguang
8 | * @Date: 2021/1/26 15:09
9 | * @version: v1.0.0
10 | * @description:
11 | */
12 | @SpringBootApplication
13 | public class Application {
14 |
15 | public static void main(String[] args) {
16 | SpringApplication.run(Application.class, args);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/Swagger2.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import springfox.documentation.builders.ApiInfoBuilder;
6 | import springfox.documentation.builders.PathSelectors;
7 | import springfox.documentation.builders.RequestHandlerSelectors;
8 | import springfox.documentation.service.ApiInfo;
9 | import springfox.documentation.spi.DocumentationType;
10 | import springfox.documentation.spring.web.plugins.Docket;
11 | import springfox.documentation.swagger2.annotations.EnableSwagger2;
12 |
13 | /**
14 | * @Author: keguang
15 | * @Date: 2019/7/30 17:33
16 | * @version: v1.0.0
17 | * @description:
18 | */
19 | @Configuration
20 | @EnableSwagger2
21 | public class Swagger2 {
22 |
23 | @Bean
24 | public Docket createRestApi(){
25 | return new Docket(DocumentationType.SWAGGER_2)
26 | .apiInfo(apiInfo())
27 | .select()
28 | .apis(RequestHandlerSelectors.basePackage(""))
29 | .paths(PathSelectors.any())
30 | .build();
31 | }
32 |
33 | private ApiInfo apiInfo(){
34 | return new ApiInfoBuilder()
35 | .title("Spring Boot中使用Swagger2构建RESTful APIs")
36 | .description("ikeguang")
37 | .termsOfServiceUrl("ikeguang.com")
38 | .contact("ikeguang")
39 | .version("1.0")
40 | .build();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/config/MyWebConfigurer.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.config;
2 |
3 | import org.springframework.boot.SpringBootConfiguration;
4 | import org.springframework.web.servlet.config.annotation.CorsRegistry;
5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
6 |
7 | /**
8 | * @Author: keguang
9 | * @Date: 2021/1/26 15:48
10 | * @version: v1.0.0
11 | * @description:
12 | */
13 | @SpringBootConfiguration
14 | public class MyWebConfigurer implements WebMvcConfigurer{
15 |
16 | /**
17 | * 请求允许跨域
18 | * @param registry
19 | */
20 | @Override
21 | public void addCorsMappings(CorsRegistry registry) {
22 | registry.addMapping("/**")
23 | .allowedOrigins("http://localhost:8080")
24 | .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
25 | .allowedHeaders("*")
26 | .maxAge(3600);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/config/MysqlConfig.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.config;
2 |
3 | import org.hibernate.dialect.MySQL5Dialect;
4 | import org.springframework.stereotype.Component;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/16 9:58
9 | * @ version: v1.0.0
10 | * @ description: 解决hibernate自动建表字符集为latin不能插入中文的问题。
11 | */
12 | @Component
13 | @SuppressWarnings("deprecation")
14 | public class MysqlConfig extends MySQL5Dialect{
15 |
16 | @Override
17 | public String getTableTypeString() {
18 | return "ENGINE=InnoDB DEFAULT CHARSET=utf8";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/model/Article.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.model;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.ToString;
7 |
8 | import javax.persistence.*;
9 | import javax.validation.constraints.NotNull;
10 | import java.util.Date;
11 |
12 | /**
13 | * @Author: keguang
14 | * @Date: 2021/1/27 16:51
15 | * @version: v1.0.0
16 | * @description:
17 | */
18 | @NoArgsConstructor
19 | @AllArgsConstructor
20 | @ToString
21 | @Data
22 | @Table(name = "articles")
23 | @Entity
24 | public class Article {
25 |
26 | @Id
27 | @GeneratedValue(strategy = GenerationType.AUTO)
28 | @Column(name = "id")
29 | @NotNull(message = "id不能为 null")
30 | private long id;
31 |
32 | @Column(nullable = false)
33 | private String title;
34 |
35 | @Column(nullable = false)
36 | private String contentHtml;
37 |
38 | @Column(nullable = false)
39 | private String contentMd;
40 |
41 | /**
42 | * article release date
43 | */
44 | @Column(nullable = false)
45 | private Date date;
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/model/User2.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.model;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.ToString;
7 |
8 | import javax.persistence.*;
9 | import java.io.Serializable;
10 |
11 | /**
12 | * @ Author: keguang
13 | * @ Date: 2019/6/24 20:18
14 | * @ version: v1.0.0
15 | * @ description:
16 | */
17 | @Entity
18 | @NoArgsConstructor
19 | @AllArgsConstructor
20 | @Data
21 | public class User2 implements Serializable{
22 | private static final long serialVersionUID = 1L;
23 |
24 | @Id
25 | @GeneratedValue(strategy = GenerationType.IDENTITY)
26 | private Long id;
27 |
28 | @Column(nullable = false, unique = true)
29 | private String userName;
30 |
31 | @Column(nullable = false)
32 | private String passWord;
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/repository/ArticleRepository.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.repository;
2 |
3 | import com.ikeguang.vue.model.Article;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | /**
7 | * @Author: keguang
8 | * @Date: 2021/1/27 18:34
9 | * @version: v1.0.0
10 | * @description:
11 | */
12 | public interface ArticleRepository extends JpaRepository {
13 |
14 | Article findByTitle(String title);
15 | }
16 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/repository/UserRepository.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.repository;
2 |
3 | import com.ikeguang.vue.model.User2;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | /**
7 | * @Author: keguang
8 | * @Date: 2019/7/18 10:23
9 | * @version: v1.0.0
10 | * @description:
11 | */
12 | public interface UserRepository extends JpaRepository{
13 |
14 | User2 findById(long id);
15 | }
16 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/result/Result.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.result;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | /**
8 | * @Author: keguang
9 | * @Date: 2021/1/26 14:54
10 | * @version: v1.0.0
11 | * @description:
12 | */
13 | @NoArgsConstructor
14 | @AllArgsConstructor
15 | @Data
16 | public class Result {
17 |
18 | private int code;
19 | private String msg;
20 | private Object result;
21 | }
22 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/result/ResultCode.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.result;
2 |
3 | /**
4 | * @author Evan
5 | * @date 2019/4
6 | */
7 | public enum ResultCode {
8 | SUCCESS(200),
9 | FAIL(400),
10 | UNAUTHORIZED(401),
11 | NOT_FOUND(404),
12 | INTERNAL_SERVER_ERROR(500);
13 |
14 | public int code;
15 |
16 | ResultCode(int code) {
17 | this.code = code;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/service/IArticleService.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.service;
2 |
3 | import com.ikeguang.vue.model.Article;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * @Author: keguang
9 | * @Date: 2021/1/27 18:36
10 | * @version: v1.0.0
11 | * @description:
12 | */
13 | public interface IArticleService {
14 |
15 | void saveArticle(Article article);
16 |
17 | List list();
18 |
19 | Article findByTitle(String title);
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/service/IUserService.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.service;
2 |
3 | import com.ikeguang.vue.model.User2;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * @Author: keguang
9 | * @Date: 2019/7/18 10:26
10 | * @version: v1.0.0
11 | * @description:
12 | */
13 | public interface IUserService {
14 |
15 | List getUserList();
16 |
17 | User2 findUserById(long id);
18 |
19 | /**
20 | * 保存用户
21 | * @param user
22 | */
23 | void saveUser(User2 user);
24 | }
25 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/service/impl/ArticleServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.service.impl;
2 |
3 | import com.ikeguang.vue.model.Article;
4 | import com.ikeguang.vue.repository.ArticleRepository;
5 | import com.ikeguang.vue.service.IArticleService;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * @Author: keguang
13 | * @Date: 2021/1/27 18:37
14 | * @version: v1.0.0
15 | * @description:
16 | */
17 | @Service
18 | public class ArticleServiceImpl implements IArticleService {
19 | @Autowired
20 | ArticleRepository articleRepository;
21 |
22 | @Override
23 | public void saveArticle(Article article) {
24 | articleRepository.save(article);
25 | }
26 |
27 | @Override
28 | public List list() {
29 | return articleRepository.findAll();
30 | }
31 |
32 | @Override
33 | public Article findByTitle(String title) {
34 | return articleRepository.findByTitle(title);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/service/impl/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.service.impl;
2 |
3 | import com.ikeguang.vue.model.User2;
4 | import com.ikeguang.vue.repository.UserRepository;
5 | import com.ikeguang.vue.service.IUserService;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * @Author: keguang
13 | * @Date: 2019/7/18 10:27
14 | * @version: v1.0.0
15 | * @description:
16 | */
17 | @Service
18 | public class UserServiceImpl implements IUserService {
19 |
20 | @Autowired
21 | UserRepository userRepository;
22 |
23 | @Override
24 | public List getUserList() {
25 | return userRepository.findAll();
26 | }
27 |
28 | @Override
29 | public User2 findUserById(long id) {
30 | return userRepository.findById(id);
31 | }
32 |
33 | @Override
34 | public void saveUser(User2 user) {
35 | userRepository.save(user);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/utils/ResultConfigFactory.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.utils;
2 |
3 | import com.ikeguang.vue.result.Result;
4 | import com.ikeguang.vue.result.ResultCode;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * @Author: keguang
10 | * @Date: 2021/1/26 14:57
11 | * @version: v1.0.0
12 | * @description:
13 | */
14 | public class ResultConfigFactory {
15 |
16 | public static Result builtResult(Object object){
17 | return new Result(ResultCode.SUCCESS.code, "成功", object);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/web/ArticleController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.web;
2 |
3 | import com.ikeguang.vue.model.Article;
4 | import com.ikeguang.vue.result.Result;
5 | import com.ikeguang.vue.service.IArticleService;
6 | import com.ikeguang.vue.utils.ResultConfigFactory;
7 | import io.swagger.annotations.Api;
8 | import io.swagger.annotations.ApiOperation;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.web.bind.annotation.*;
11 |
12 | /**
13 | * @Author: keguang
14 | * @Date: 2021/1/28 9:50
15 | * @version: v1.0.0
16 | * @description:
17 | */
18 | @RestController
19 | @RequestMapping("/api/article")
20 | @Api(tags = "文章管理")
21 | public class ArticleController {
22 |
23 | @Autowired
24 | IArticleService iArticleService;
25 |
26 | @ApiOperation("保存文章")
27 | @PostMapping("/addArticle")
28 | public Result addArticle(@RequestBody Article article){
29 | System.out.println(article);
30 | iArticleService.saveArticle(article);
31 |
32 | return ResultConfigFactory.builtResult(null);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/java/com/ikeguang/vue/web/UserController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.web;
2 |
3 | import com.ikeguang.vue.result.Result;
4 | import com.ikeguang.vue.service.IUserService;
5 | import com.ikeguang.vue.utils.ResultConfigFactory;
6 | import io.swagger.annotations.Api;
7 | import io.swagger.annotations.ApiOperation;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.web.bind.annotation.GetMapping;
10 | import org.springframework.web.bind.annotation.RequestMapping;
11 | import org.springframework.web.bind.annotation.RestController;
12 |
13 | /**
14 | * @Author: keguang
15 | * @Date: 2019/7/18 10:29
16 | * @version: v1.0.0
17 | * @description:
18 | */
19 | @RestController
20 | @RequestMapping("/api")
21 | @Api(tags = "用户管理")
22 | public class UserController {
23 |
24 | @Autowired
25 | IUserService IUserService;
26 |
27 | @ApiOperation("获取用户列表")
28 | @GetMapping("/users")
29 | public Result list(){
30 | return ResultConfigFactory.builtResult(IUserService.getUserList());
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/resources/application-test.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:mysql://192.168.1.102/test?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=true
2 | spring.datasource.username=root
3 | spring.datasource.password=root
4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
5 |
6 | spring.jpa.properties.hibernate.hbm2ddl.auto=update
7 | spring.jpa.properties.hibernate.dialect=com.ikeguang.vue.config.MysqlConfig
8 | spring.jpa.show-sql= true
9 |
10 | spring.thymeleaf.cache=false
11 |
12 | # \u7AEF\u53E3
13 | server.port=8043
14 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=true
2 | spring.datasource.username=root
3 | spring.datasource.password=root
4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
5 |
6 | spring.jpa.properties.hibernate.hbm2ddl.auto=update
7 | spring.jpa.properties.hibernate.dialect=com.ikeguang.vue.config.MysqlConfig
8 | spring.jpa.show-sql= true
9 |
10 | spring.thymeleaf.cache=false
11 |
12 | # \u7AEF\u53E3
13 | server.port=8043
14 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/test/java/com/ikeguang/vue/service/IArticleServiceTests.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.service;
2 |
3 | import com.ikeguang.vue.model.Article;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.context.SpringBootTest;
8 | import org.springframework.test.context.junit4.SpringRunner;
9 |
10 | import java.util.Date;
11 | import java.util.List;
12 |
13 | /**
14 | * @Author: keguang
15 | * @Date: 2021/1/27 18:38
16 | * @version: v1.0.0
17 | * @description:
18 | */
19 | @SpringBootTest
20 | @RunWith(SpringRunner.class)
21 | public class IArticleServiceTests {
22 |
23 | @Autowired
24 | IArticleService iArticleService;
25 |
26 | @Test
27 | public void saveArticleTest(){
28 | Article article = new Article(1L, "test", "test", "test", new Date());
29 | iArticleService.saveArticle(article);
30 | }
31 |
32 | @Test
33 | public void lisTest(){
34 | List list = iArticleService.list();
35 | System.out.println(list);
36 | }
37 |
38 | @Test
39 | public void findByTitleTest(){
40 | Article article = iArticleService.findByTitle("test");
41 | System.out.println(article);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/spring-boot-vue/src/test/java/com/ikeguang/vue/service/User2ServiceTests.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.vue.service;
2 |
3 | import com.ikeguang.vue.model.User2;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.context.SpringBootTest;
8 | import org.springframework.test.context.junit4.SpringRunner;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * @Author: keguang
14 | * @Date: 2021/1/26 15:05
15 | * @version: v1.0.0
16 | * @description:
17 | */
18 | @SpringBootTest
19 | @RunWith(SpringRunner.class)
20 | public class User2ServiceTests {
21 |
22 | @Autowired
23 | IUserService IUserService;
24 |
25 | @Test
26 | public void saveUserTest(){
27 | for(long i = 10;i < 50; i++){
28 | User2 user = new User2(i, String.format("柯广 %s", i), String.format("keguang%s", i));
29 | IUserService.saveUser(user);
30 | }
31 |
32 | }
33 |
34 | @Test
35 | public void getUserList(){
36 | List user2List = IUserService.getUserList();
37 | System.out.println(user2List);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/spring-boot-web/src/main/java/com/ikeguang/web/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.web;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/6/28 9:31
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 |
13 | @SpringBootApplication
14 | public class Application {
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(Application.class, args);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/spring-boot-web/src/main/java/com/ikeguang/web/controller/HelloController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.web.controller;
2 |
3 | import org.springframework.ui.Model;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 | import org.springframework.web.bind.annotation.RestController;
6 |
7 | import java.util.Locale;
8 |
9 | /**
10 | * @ Author: keguang
11 | * @ Date: 2019/6/19 20:26
12 | * @ version: v1.0.0
13 | * @ description:
14 | */
15 |
16 | @RestController
17 | public class HelloController {
18 |
19 | @RequestMapping("/hello")
20 | public String hello(Locale locale, Model model){
21 | return "Hello World";
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/spring-boot-web/src/main/java/com/ikeguang/web/controller/ThymeleafController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.web.controller;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.ui.Model;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 |
7 | import java.text.DateFormat;
8 | import java.util.Date;
9 | import java.util.Locale;
10 |
11 | /**
12 | * @ Author: keguang
13 | * @ Date: 2019/6/27 20:24
14 | * @ version: v1.0.0
15 | * @ description:
16 | */
17 | @Controller
18 | public class ThymeleafController {
19 |
20 | @RequestMapping("/hi")
21 | public String hello(Locale locale, Model model){
22 | model.addAttribute("greeting", "Hello");
23 | Date date = new Date();
24 | DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
25 | String formettedDate = dateFormat.format(date);
26 | model.addAttribute("currentTime", formettedDate);
27 |
28 | return "hello";
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/spring-boot-web/src/main/java/com/ikeguang/web/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.web.controller;
2 |
3 | import com.ikeguang.web.model.User;
4 | import com.ikeguang.web.repository.UserRepository;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * @ Author: keguang
13 | * @ Date: 2019/6/25 20:22
14 | * @ version: v1.0.0
15 | * @ description:
16 | */
17 |
18 | @RestController
19 | public class UserController {
20 | @Autowired
21 | private UserRepository userRepository;
22 |
23 | @RequestMapping("/getUser")
24 | public User getUser(){
25 | User user = userRepository.findByUserName("bb");
26 | System.out.println("若下面没出现“无缓存的时候调用”字样且能打印出数据表示测试成功");
27 | return user;
28 | }
29 |
30 | @RequestMapping("/getUsers")
31 | public List getUsers(){
32 | List users = userRepository.findAll();
33 | System.out.println("若下面没出现“无缓存的时候调用”字样且能打印出数据表示测试成功");
34 | return users;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/spring-boot-web/src/main/java/com/ikeguang/web/repository/UserRepository.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.web.repository;
2 |
3 | import com.ikeguang.web.model.User;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/6/24 20:23
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 | public interface UserRepository extends JpaRepository {
13 |
14 | User findByUserName(String userName);
15 | User findByUserNameOrEmail(String username, String email);
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/spring-boot-web/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC&characterEncoding=utf-8
2 | spring.datasource.username=root
3 | spring.datasource.password=root
4 | # spring.datasource.driver-class-name=com.mysql.jdbc.Driver
5 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
6 |
7 | spring.jpa.properties.hibernate.hbm2ddl.auto=update
8 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
9 | spring.jpa.show-sql= true
--------------------------------------------------------------------------------
/spring-boot-web/src/main/resources/static.images/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ddxygq/spring-boot-learn/50a11a4840db13c24dc3f854a2ccabf3b2bcede8/spring-boot-web/src/main/resources/static.images/favicon.png
--------------------------------------------------------------------------------
/spring-boot-web/src/main/resources/static/css/starter.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding-top: 50px;
3 | }
4 |
5 | .starter-template {
6 | padding: 40px 15px;
7 | text-align: center;
8 | }
--------------------------------------------------------------------------------
/spring-boot-web/src/main/resources/templates/hello.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | (navbar)
6 |
7 |
8 |
9 |
Spring MVC / Thymeleaf / Bootstrap
10 |
(greeting)
11 |
The current time is (time)
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/sprint-boot-scheduler/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-learn
7 | com.ikeguang
8 | 1.0.0
9 |
10 | 4.0.0
11 |
12 | sprint-boot-scheduler
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-starter-test
22 |
23 |
24 |
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-maven-plugin
30 |
31 | true
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/sprint-boot-scheduler/src/main/java/com/ikeguang/scheduler/Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.scheduler;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.scheduling.annotation.EnableScheduling;
6 |
7 | /**
8 | * @ Author: keguang
9 | * @ Date: 2019/7/5 17:43
10 | * @ version: v1.0.0
11 | * @ description: @EnableScheduling 开启定时
12 | */
13 | @SpringBootApplication
14 | @EnableScheduling
15 | public class Application {
16 |
17 | public static void main(String[] args) {
18 | SpringApplication.run(Application.class, args);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/sprint-boot-scheduler/src/main/java/com/ikeguang/scheduler/task/SchedulerTask.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.scheduler.task;
2 |
3 | import org.springframework.scheduling.annotation.Scheduled;
4 | import org.springframework.stereotype.Component;
5 |
6 | /**
7 | * @ Author: keguang
8 | * @ Date: 2019/7/5 17:51
9 | * @ version: v1.0.0
10 | * @ description:
11 | */
12 | @Component
13 | public class SchedulerTask {
14 |
15 | private int count = 0;
16 |
17 | @Scheduled(cron = "*/5 * * * * ?")
18 | private void process(){
19 | System.out.println("this is scheduler task " + (count++));
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/sprint-boot-scheduler/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=spirng-boot-scheduler
--------------------------------------------------------------------------------
/sprint-boot-scheduler/src/test/java/com/ikeguang/scheduler/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.scheduler;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | /**
9 | * @ Author: keguang
10 | * @ Date: 2019/7/5 17:54
11 | * @ version: v1.0.0
12 | * @ description:
13 | */
14 |
15 | @RunWith(SpringRunner.class)
16 | @SpringBootTest
17 | public class ApplicationTest {
18 |
19 | @Test
20 | public void contextLoads(){
21 | System.out.println("hello world");
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/sprint-boot-swagger3/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-learn
7 | com.ikeguang
8 | 1.0.0
9 |
10 | 4.0.0
11 |
12 | sprint-boot-swagger3
13 |
14 |
15 |
16 |
17 | org.springframework.boot
18 | spring-boot-starter
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-web
24 |
25 |
26 |
27 |
28 | io.springfox
29 | springfox-boot-starter
30 | 3.0.0
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/sprint-boot-swagger3/src/main/java/com/ikeguang/swagger3/Swagger3.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.swagger3;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import springfox.documentation.builders.ApiInfoBuilder;
6 | import springfox.documentation.builders.RequestHandlerSelectors;
7 | import springfox.documentation.service.Contact;
8 | import springfox.documentation.spi.DocumentationType;
9 | import springfox.documentation.spring.web.plugins.Docket;
10 |
11 | /**
12 | * @Author: keguang
13 | * @Date: 2022/7/22 17:41
14 | * @version: v1.0.0
15 | * @description:
16 | */
17 | @Configuration
18 | public class Swagger3 {
19 |
20 | @Bean
21 | Docket docket() {
22 | return new Docket(DocumentationType.OAS_30)
23 | .apiInfo(new ApiInfoBuilder()
24 | .title("SpringBoot 应用")
25 | .version("v1.0")
26 | .description("Swagger3.0 测试")
27 | .contact(new Contact("ikeguang.com", "https://www.ikeguang.com/", "ikeguang@126.com"))
28 | .build())
29 | .select()
30 | .apis(RequestHandlerSelectors.basePackage("com.ikeguang.swagger3.controller"))
31 | .build();
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/sprint-boot-swagger3/src/main/java/com/ikeguang/swagger3/Swagger3Application.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.swagger3;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import springfox.documentation.oas.annotations.EnableOpenApi;
6 | import springfox.documentation.swagger2.annotations.EnableSwagger2;
7 |
8 | /**
9 | * @Author: keguang
10 | * @Date: 2022/7/22 17:30
11 | * @version: v1.0.0
12 | * @description:
13 | */
14 | @SpringBootApplication
15 | @EnableSwagger2
16 | @EnableOpenApi
17 | public class Swagger3Application {
18 |
19 | public static void main(String[] args) {
20 | SpringApplication.run(Swagger3Application.class, args) ;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/sprint-boot-swagger3/src/main/java/com/ikeguang/swagger3/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.ikeguang.swagger3.controller;
2 |
3 | import io.swagger.annotations.Api;
4 | import io.swagger.annotations.ApiOperation;
5 | import org.springframework.web.bind.annotation.GetMapping;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | /**
10 | * @Author: keguang
11 | * @Date: 2022/7/22 18:25
12 | * @version: v1.0.0
13 | * @description:
14 | */
15 | @RestController
16 | @Api(tags = "用户管理")
17 | @RequestMapping("/user")
18 | public class UserController {
19 |
20 | @GetMapping()
21 | @ApiOperation("查询用户")
22 | public String list() {
23 | return "查询成功";
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------