├── README.md ├── mq-demo ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── MqApplication.java │ │ │ └── rabbitmq │ │ │ ├── api │ │ │ └── RabbitMqApi.java │ │ │ ├── common │ │ │ └── SwaggerConfig.java │ │ │ ├── direct │ │ │ ├── DirectConfig.java │ │ │ ├── DirectConsumer.java │ │ │ └── DirectProducer.java │ │ │ ├── fanout │ │ │ ├── FanoutConfig.java │ │ │ ├── FanoutConsumer.java │ │ │ └── FanoutProducer.java │ │ │ ├── headers │ │ │ ├── HeadersConfig.java │ │ │ ├── HeadersConsumer.java │ │ │ └── HeadersProducer.java │ │ │ └── topic │ │ │ ├── TopicConfig.java │ │ │ ├── TopicConsumer.java │ │ │ └── TopicProducer.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── yanger │ └── MqApplicationTests.java ├── p1-springboot-start ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ └── start │ │ │ └── HelloApi.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p10-springboot-redis ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── jdbcTemplate │ │ │ └── description.txt │ │ │ ├── jpa │ │ │ └── description.txt │ │ │ ├── mybatis │ │ │ └── description.txt │ │ │ ├── redis │ │ │ ├── api │ │ │ │ └── UserApi.java │ │ │ ├── dao │ │ │ │ └── IUserDao.java │ │ │ ├── po │ │ │ │ └── User.java │ │ │ ├── service │ │ │ │ └── UserService.java │ │ │ └── util │ │ │ │ ├── CacheConfig.java │ │ │ │ └── CacheDao.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ ├── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ │ │ └── transaction │ │ │ ├── api │ │ │ └── TransactionApi.java │ │ │ ├── dao │ │ │ └── TransactionDao.java │ │ │ └── service │ │ │ └── TransactionService.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── config │ │ └── config.properties │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p11-springboot-lombok ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── jdbcTemplate │ │ │ └── description.txt │ │ │ ├── jpa │ │ │ └── description.txt │ │ │ ├── lombok │ │ │ ├── Demo.java │ │ │ └── description.txt │ │ │ ├── mybatis │ │ │ ├── api │ │ │ │ └── UserApi.java │ │ │ ├── dao │ │ │ │ └── IUserDao.java │ │ │ ├── po │ │ │ │ └── User.java │ │ │ └── service │ │ │ │ └── UserService.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── config │ │ └── config.properties │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p12-springboot-muti-jdbcTemplate ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── jdbcTemplate │ │ │ ├── api │ │ │ │ └── UserApi.java │ │ │ ├── dao │ │ │ │ ├── IUserDao.java │ │ │ │ └── UserDao.java │ │ │ ├── po │ │ │ │ └── User.java │ │ │ ├── service │ │ │ │ └── UserService.java │ │ │ └── util │ │ │ │ ├── DataSourceConfig.java │ │ │ │ └── JdbcTemplateConfig.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── config │ │ └── config.properties │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p13-springboot-muti-jpa ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── jdbcTemplate │ │ │ └── description.txt │ │ │ ├── jpa │ │ │ ├── api │ │ │ │ └── UserApi.java │ │ │ ├── dao │ │ │ │ └── IUserDao.java │ │ │ ├── po │ │ │ │ └── User.java │ │ │ ├── sdao │ │ │ │ └── ISlaveUserDao.java │ │ │ ├── service │ │ │ │ └── UserService.java │ │ │ └── util │ │ │ │ ├── DataSourceConfig.java │ │ │ │ ├── MasterJpaConfig.java │ │ │ │ └── SlaveJpaConfig.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── config │ │ └── config.properties │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p14-springboot-muti-mybatis ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── jdbcTemplate │ │ │ └── description.txt │ │ │ ├── jpa │ │ │ └── description.txt │ │ │ ├── mybatis │ │ │ ├── api │ │ │ │ └── UserApi.java │ │ │ ├── dao │ │ │ │ └── IUserDao.java │ │ │ ├── po │ │ │ │ └── User.java │ │ │ ├── sdao │ │ │ │ └── ISlaveUserDao.java │ │ │ ├── service │ │ │ │ └── UserService.java │ │ │ └── util │ │ │ │ ├── DataSourceConfig.java │ │ │ │ ├── MasterSqlSessionConfig.java │ │ │ │ └── SlaveSqlSessionConfig.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── config │ │ └── config.properties │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p15-springboot-muti-aop-mybatis ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── jdbcTemplate │ │ │ └── description.txt │ │ │ ├── jpa │ │ │ └── description.txt │ │ │ ├── mybatis │ │ │ ├── api │ │ │ │ └── UserApi.java │ │ │ ├── dao │ │ │ │ └── IUserDao.java │ │ │ ├── po │ │ │ │ └── User.java │ │ │ ├── service │ │ │ │ └── UserService.java │ │ │ └── util │ │ │ │ ├── DS.java │ │ │ │ ├── DataSourceConfig.java │ │ │ │ ├── DataSourceContextHolder.java │ │ │ │ ├── DynamicDataSource.java │ │ │ │ └── DynamicDataSourceAspect.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── config │ │ └── config.properties │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p16-springboot-mybatis-sharding ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── jdbcTemplate │ │ │ └── description.txt │ │ │ ├── jpa │ │ │ └── description.txt │ │ │ ├── mybatis │ │ │ ├── api │ │ │ │ └── UserApi.java │ │ │ ├── dao │ │ │ │ └── IUserDao.java │ │ │ ├── po │ │ │ │ └── User.java │ │ │ └── service │ │ │ │ └── UserService.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── config │ │ └── config.properties │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p17-springboot-jsp ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── jsp │ │ │ └── IndexApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ ├── resources │ │ ├── META-INF │ │ │ └── resources │ │ │ │ └── pages │ │ │ │ ├── hello.jsp │ │ │ │ └── mv.jsp │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ └── application.yml │ └── webapp │ │ └── templates │ │ ├── hello.jsp │ │ └── mv.jsp │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p18-springboot-thymeleaf ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ ├── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ │ │ └── thymeleaf │ │ │ └── IndexApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── templates │ │ ├── hello.html │ │ └── mv.html │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p19-springboot-freemarker ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── freemarker │ │ │ └── IndexApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── templates │ │ ├── hello.ftl │ │ └── mv.ftl │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p2-springboot-config ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ └── start │ │ │ └── HelloApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── config │ │ └── config.properties │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p20-springboot-cache ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── cache │ │ │ ├── CacheApi.java │ │ │ ├── CacheService.java │ │ │ └── User.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ └── application.yml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p21-springboot-cache-redis ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── cache │ │ │ ├── CacheApi.java │ │ │ ├── CacheConfig.java │ │ │ ├── CacheService.java │ │ │ └── User.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ └── application.yml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p22-springboot-cache-ehcache ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── cache │ │ │ ├── CacheApi.java │ │ │ ├── CacheService.java │ │ │ └── User.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── ehcache.xml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p23-springboot-async ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── async │ │ │ ├── AsyncTask.java │ │ │ └── FutureTask.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ └── application.yml │ └── test │ └── java │ └── com │ └── yanger │ ├── SpringbootApplicationTests.java │ └── async │ └── AsyncTaskTest.java ├── p24-springboot-schedule ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── schedule │ │ │ └── Task.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ └── application.yml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p25-springboot-quartz ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── quartz │ │ │ ├── QuartzConfig.java │ │ │ └── QuartzJob1.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── dbTables │ │ ├── tables_cloudscape.sql │ │ ├── tables_cubrid.sql │ │ ├── tables_db2.sql │ │ ├── tables_db2_v72.sql │ │ ├── tables_db2_v8.sql │ │ ├── tables_db2_v95.sql │ │ ├── tables_derby.sql │ │ ├── tables_derby_previous.sql │ │ ├── tables_firebird.sql │ │ ├── tables_h2.sql │ │ ├── tables_hsqldb.sql │ │ ├── tables_hsqldb_old.sql │ │ ├── tables_informix.sql │ │ ├── tables_mysql.sql │ │ ├── tables_mysql_innodb.sql │ │ ├── tables_oracle.sql │ │ ├── tables_pointbase.sql │ │ ├── tables_postgres.sql │ │ ├── tables_sapdb.sql │ │ ├── tables_solid.sql │ │ ├── tables_sqlServer.sql │ │ └── tables_sybase.sql │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p26-springboot-exception ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── exception │ │ │ ├── AuthException.java │ │ │ ├── ExceptionApi.java │ │ │ └── GlobalExceptionHandler.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ ├── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ └── application.yml │ └── webapp │ │ └── templates │ │ └── error.jsp │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p27-springboot-log4j ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── log │ │ │ └── LogApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── log4j2.xml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p28-springboot-actuator ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── actuator │ │ │ └── ActuatorApi.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ └── application.yml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p29-springboot-admin ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── admin │ │ │ ├── AdminConfig.java │ │ │ └── SecuritySecureConfig.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ └── application.yml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p3-springboot-swagger2 ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── config │ │ └── config.properties │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p30-springboot-restTemplate ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── rest │ │ │ ├── ClientApi.java │ │ │ ├── RestConfig.java │ │ │ ├── ServerApi.java │ │ │ └── User.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ └── application.yml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p31-springboot-fileupload ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ └── application.yml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p32-springboot-mail ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ └── application.yml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p33-springboot-validation ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ └── application.yml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p34-springboot-xml ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ └── application.yml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p4-springboot-devtools ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── config │ │ └── config.properties │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p5-springboot-jdbcTemplate ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── jdbcTemplate │ │ │ ├── api │ │ │ │ └── UserApi.java │ │ │ ├── dao │ │ │ │ ├── IUserDao.java │ │ │ │ └── UserDao.java │ │ │ ├── po │ │ │ │ └── User.java │ │ │ └── service │ │ │ │ └── UserService.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── config │ │ └── config.properties │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p6-springboot-jpa ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── jdbcTemplate │ │ │ └── description.txt │ │ │ ├── jpa │ │ │ ├── api │ │ │ │ └── UserApi.java │ │ │ ├── dao │ │ │ │ └── IUserDao.java │ │ │ ├── po │ │ │ │ └── User.java │ │ │ └── service │ │ │ │ └── UserService.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── config │ │ └── config.properties │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p7-springboot-mybatis ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── jdbcTemplate │ │ │ └── description.txt │ │ │ ├── jpa │ │ │ └── description.txt │ │ │ ├── mybatis │ │ │ ├── api │ │ │ │ └── UserApi.java │ │ │ ├── dao │ │ │ │ └── IUserDao.java │ │ │ ├── po │ │ │ │ └── User.java │ │ │ └── service │ │ │ │ └── UserService.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ └── config │ │ └── config.properties │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java ├── p8-springboot-mybatis-xml ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yanger │ │ │ ├── SpringbootApplication.java │ │ │ ├── config │ │ │ ├── Boy.java │ │ │ ├── ConfigApi.java │ │ │ └── Girl.java │ │ │ ├── devtools │ │ │ └── DevtoolsApi.java │ │ │ ├── jdbcTemplate │ │ │ └── description.txt │ │ │ ├── jpa │ │ │ └── description.txt │ │ │ ├── mybatis │ │ │ ├── api │ │ │ │ └── UserApi.java │ │ │ ├── dao │ │ │ │ └── IUserDao.java │ │ │ ├── po │ │ │ │ └── User.java │ │ │ └── service │ │ │ │ └── UserService.java │ │ │ ├── start │ │ │ └── HelloApi.java │ │ │ └── swagger2 │ │ │ ├── Book.java │ │ │ ├── Swagger2.java │ │ │ └── SwaggerApi.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ ├── config │ │ └── config.properties │ │ └── mybatis │ │ └── UserDao.xml │ └── test │ └── java │ └── com │ └── yanger │ └── SpringbootApplicationTests.java └── p9-springboot-transaction ├── .gitignore ├── .mvn └── wrapper │ ├── MavenWrapperDownloader.java │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── yanger │ │ ├── SpringbootApplication.java │ │ ├── config │ │ ├── Boy.java │ │ ├── ConfigApi.java │ │ └── Girl.java │ │ ├── devtools │ │ └── DevtoolsApi.java │ │ ├── jdbcTemplate │ │ └── description.txt │ │ ├── jpa │ │ └── description.txt │ │ ├── mybatis │ │ ├── api │ │ │ └── UserApi.java │ │ ├── dao │ │ │ └── IUserDao.java │ │ ├── po │ │ │ └── User.java │ │ └── service │ │ │ └── UserService.java │ │ ├── start │ │ └── HelloApi.java │ │ ├── swagger2 │ │ ├── Book.java │ │ ├── Swagger2.java │ │ └── SwaggerApi.java │ │ └── transaction │ │ ├── api │ │ └── TransactionApi.java │ │ ├── dao │ │ └── TransactionDao.java │ │ └── service │ │ └── TransactionService.java └── resources │ ├── application-dev.yml │ ├── application-prod.yml │ ├── application.yml │ ├── config │ └── config.properties │ └── mybatis │ └── UserDao.xml └── test └── java └── com └── yanger └── SpringbootApplicationTests.java /mq-demo/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | -------------------------------------------------------------------------------- /mq-demo/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/mq-demo/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /mq-demo/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /mq-demo/src/main/java/com/yanger/MqApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | 7 | import springfox.documentation.builders.ApiInfoBuilder; 8 | import springfox.documentation.builders.PathSelectors; 9 | import springfox.documentation.builders.RequestHandlerSelectors; 10 | import springfox.documentation.service.ApiInfo; 11 | import springfox.documentation.service.Contact; 12 | import springfox.documentation.spi.DocumentationType; 13 | import springfox.documentation.spring.web.plugins.Docket; 14 | 15 | @SpringBootApplication 16 | public class MqApplication { 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(MqApplication.class, args); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /mq-demo/src/main/java/com/yanger/rabbitmq/direct/DirectConfig.java: -------------------------------------------------------------------------------- 1 | package com.yanger.rabbitmq.direct; 2 | 3 | import org.springframework.amqp.core.Queue; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | @Configuration 8 | public class DirectConfig { 9 | 10 | /* 11 | direct 类型的行为是"先匹配, 再投送". 即在绑定时设定一个 routingkey, 消息的routingkey 匹配时, 12 | 才会被交换器投送到绑定的队列中去.是RabbitMQ默认的交换机模式,也是最简单的模式,根据key全文匹配去寻找队列。 13 | */ 14 | 15 | public static final String QUEUE1 = "direct_queue_1"; 16 | 17 | public static final String QUEUE2 = "direct_queue_2"; 18 | 19 | @Bean 20 | public Queue directQueue1() { 21 | return new Queue(QUEUE1); 22 | } 23 | 24 | @Bean 25 | public Queue directQueue2() { 26 | // true声明持久队列,队列在服务器重启后存活 27 | return new Queue(QUEUE2, true); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /mq-demo/src/main/java/com/yanger/rabbitmq/direct/DirectConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yanger.rabbitmq.direct; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 4 | import org.springframework.stereotype.Component; 5 | 6 | // 消费者,direct类型根据routingkey完全匹配 7 | @Component 8 | public class DirectConsumer { 9 | 10 | // 监听Queue的消息:direct_queue_1 11 | @RabbitListener(queues = DirectConfig.QUEUE1) 12 | public void directReceiv1(String msg) { 13 | System.out.println(DirectConfig.QUEUE1 + "接收消息:" + msg); 14 | } 15 | 16 | // 监听Queue的消息:direct_queue_2 17 | @RabbitListener(queues = DirectConfig.QUEUE2) 18 | public void directReceiv2(String msg) { 19 | System.out.println(DirectConfig.QUEUE2 + "接收消息:" + msg); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /mq-demo/src/main/java/com/yanger/rabbitmq/direct/DirectProducer.java: -------------------------------------------------------------------------------- 1 | package com.yanger.rabbitmq.direct; 2 | 3 | import org.springframework.amqp.core.AmqpTemplate; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | // 生产者 8 | @Component 9 | public class DirectProducer { 10 | 11 | @Autowired 12 | private AmqpTemplate rabbitTemplate; 13 | 14 | public void send(String msg) { 15 | System.out.println("direct策略消息生产者发送消息:" + msg); 16 | // 参数:路由、消息,这里我们指定路由与队列的路由规则完全匹配 17 | rabbitTemplate.convertAndSend("direct_queue_1", "direct_queue_1路由的的消息-" + msg); 18 | rabbitTemplate.convertAndSend("direct_queue_2", "direct_queue_2路由的的消息-" + msg); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /mq-demo/src/main/java/com/yanger/rabbitmq/fanout/FanoutConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yanger.rabbitmq.fanout; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 4 | import org.springframework.stereotype.Component; 5 | 6 | //fanout策略,队列绑定到交换机即可 7 | @Component 8 | public class FanoutConsumer { 9 | 10 | // 监听Queue的消息:fanout_queue_1 11 | @RabbitListener(queues = FanoutConfig.QUEUE1) 12 | public void fanoutReceiv1(String msg) { 13 | System.out.println(FanoutConfig.QUEUE1 + "接收消息:" + msg); 14 | } 15 | 16 | // 监听Queue的消息:fanout_queue_2 17 | @RabbitListener(queues = FanoutConfig.QUEUE2) 18 | public void fanoutReceiv2(String msg) { 19 | System.out.println(FanoutConfig.QUEUE2 + "接收消息:" + msg); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /mq-demo/src/main/java/com/yanger/rabbitmq/fanout/FanoutProducer.java: -------------------------------------------------------------------------------- 1 | package com.yanger.rabbitmq.fanout; 2 | 3 | import org.springframework.amqp.core.AmqpTemplate; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class FanoutProducer { 9 | 10 | @Autowired 11 | private AmqpTemplate rabbitTemplate; 12 | 13 | public void send(String msg) { 14 | System.out.println("fanout策略消息生产者发送消息:" + msg); 15 | rabbitTemplate.convertAndSend("fanout", "", "fanout的的消息-" + msg); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /mq-demo/src/main/java/com/yanger/rabbitmq/headers/HeadersConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yanger.rabbitmq.headers; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 4 | import org.springframework.stereotype.Component; 5 | 6 | //headers策略,根据headers中map属性一个或全部匹配 7 | @Component 8 | public class HeadersConsumer { 9 | 10 | // 监听Queue的消息:headers_queue_1,headers属性全部匹配 11 | @RabbitListener(queues = HeadersConfig.QUEUE1) 12 | public void headersReceiv1(byte[] msg) { 13 | System.out.println(HeadersConfig.QUEUE1 + "规则headers属性全部匹配接收消息:" + new String(msg)); 14 | } 15 | 16 | // 监听Queue的消息:headers_queue_2,路由规则#.headers 17 | @RabbitListener(queues = HeadersConfig.QUEUE2) 18 | public void headersReceiv2(byte[] msg) { 19 | System.out.println(HeadersConfig.QUEUE2 + "规则headers属性任意一个匹配接收消息:" + new String(msg)); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /mq-demo/src/main/java/com/yanger/rabbitmq/topic/TopicProducer.java: -------------------------------------------------------------------------------- 1 | package com.yanger.rabbitmq.topic; 2 | 3 | import org.springframework.amqp.core.AmqpTemplate; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | import com.yanger.rabbitmq.direct.DirectConfig; 8 | 9 | @Component 10 | public class TopicProducer { 11 | 12 | @Autowired 13 | private AmqpTemplate rabbitTemplate; 14 | 15 | public void send(String msg) { 16 | System.out.println("topic策略消息生产者发送消息:" + msg); 17 | // 参数:交换机、路由、消息,这里的路由中all表示任意一个或多个字符 18 | rabbitTemplate.convertAndSend("topic", "routingkey.all", "routingkey.all路由的的消息-" + msg); 19 | rabbitTemplate.convertAndSend("topic", "all.topic", "all.topic路由的的消息-" + msg); 20 | rabbitTemplate.convertAndSend("topic", "all.all", "all.all路由的的消息-" + msg); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /mq-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 19031 3 | 4 | #mq配置 5 | spring: 6 | rabbitmq: 7 | host: localhost 8 | port: 5672 9 | username: guest 10 | password: guest 11 | listener: 12 | concurrency: 10 #并发消费者的初始化值 13 | max-concurrency: 20 #并发消费者的最大值 14 | prefetch: 5 #每个消费者每次监听时可拉取处理的消息数量 15 | 16 | -------------------------------------------------------------------------------- /mq-demo/src/test/java/com/yanger/MqApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class MqApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p1-springboot-start/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p1-springboot-start/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p1-springboot-start/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p1-springboot-start/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p1-springboot-start/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p1-springboot-start/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p1-springboot-start/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /p1-springboot-start/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p10-springboot-redis/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p10-springboot-redis/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p10-springboot-redis/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p10-springboot-redis/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @MapperScan(value = "com.yanger.*.dao") 8 | @SpringBootApplication 9 | public class SpringbootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringbootApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/java/com/yanger/devtools/DevtoolsApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.devtools; 2 | 3 | import com.thoughtworks.xstream.XStream; 4 | import com.yanger.swagger2.Book; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController("devtools") 9 | public class DevtoolsApi { 10 | 11 | @GetMapping("msg") 12 | public String getMsg(){ 13 | return "Hello devtools new"; 14 | } 15 | 16 | @GetMapping("cast") 17 | public void cast(){ 18 | String xml = "xstream"; 19 | XStream xstream = new XStream(); 20 | // 指定xtream的classloader,否则会报转换异常 21 | xstream.setClassLoader(Book.class.getClassLoader()); 22 | xstream.alias("book", Book.class); 23 | Book book = (Book)xstream.fromXML(xml); 24 | System.out.print(book.getName()); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/java/com/yanger/jdbcTemplate/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/java/com/yanger/jpa/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/java/com/yanger/mybatis/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | redis包下关于User操作的与原有mybatis包下一致,删除了mybatis包下的,毕竟注入bean重复。 -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/java/com/yanger/redis/po/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.redis.po; 2 | 3 | import java.io.Serializable; 4 | 5 | // DefaultSerializer requires a Serializable payload but received an object of type [com.yanger.redis.po.User] 6 | public class User implements Serializable { 7 | 8 | private Integer id; 9 | 10 | private String username; 11 | 12 | private String password; 13 | 14 | public Integer getId() { 15 | return id; 16 | } 17 | 18 | public void setId(Integer id) { 19 | this.id = id; 20 | } 21 | 22 | public String getUsername() { 23 | return username; 24 | } 25 | 26 | public void setUsername(String username) { 27 | this.username = username; 28 | } 29 | 30 | public String getPassword() { 31 | return password; 32 | } 33 | 34 | public void setPassword(String password) { 35 | this.password = password; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/java/com/yanger/swagger2/Book.java: -------------------------------------------------------------------------------- 1 | package com.yanger.swagger2; 2 | 3 | public class Book { 4 | 5 | private String name; 6 | 7 | private String author; 8 | 9 | private Float price; 10 | 11 | public Book(){ 12 | 13 | } 14 | 15 | public Book(String name, String author, Float price) { 16 | this.name = name; 17 | this.author = author; 18 | this.price = price; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | public String getAuthor() { 30 | return author; 31 | } 32 | 33 | public void setAuthor(String author) { 34 | this.author = author; 35 | } 36 | 37 | public Float getPrice() { 38 | return price; 39 | } 40 | 41 | public void setPrice(Float price) { 42 | this.price = price; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/java/com/yanger/transaction/dao/TransactionDao.java: -------------------------------------------------------------------------------- 1 | package com.yanger.transaction.dao; 2 | 3 | import com.yanger.redis.po.User; 4 | import org.apache.ibatis.annotations.Insert; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | import org.apache.ibatis.annotations.Select; 8 | 9 | @Mapper 10 | public interface TransactionDao { 11 | 12 | @Insert("insert into user(username, password) values(#{username}, #{password})") 13 | void insert(User user); 14 | 15 | @Select("select * from user where username = #{username}") 16 | User findByUsername(@Param("username") String username); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p10-springboot-redis/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p10-springboot-redis/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p11-springboot-lombok/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p11-springboot-lombok/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p11-springboot-lombok/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p11-springboot-lombok/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/java/com/yanger/devtools/DevtoolsApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.devtools; 2 | 3 | import com.thoughtworks.xstream.XStream; 4 | import com.yanger.swagger2.Book; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController("devtools") 9 | public class DevtoolsApi { 10 | 11 | @GetMapping("msg") 12 | public String getMsg(){ 13 | return "Hello devtools new"; 14 | } 15 | 16 | @GetMapping("cast") 17 | public void cast(){ 18 | String xml = "xstream"; 19 | XStream xstream = new XStream(); 20 | // 指定xtream的classloader,否则会报转换异常 21 | xstream.setClassLoader(Book.class.getClassLoader()); 22 | xstream.alias("book", Book.class); 23 | Book book = (Book)xstream.fromXML(xml); 24 | System.out.print(book.getName()); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/java/com/yanger/jdbcTemplate/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/java/com/yanger/jpa/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/java/com/yanger/lombok/Demo.java: -------------------------------------------------------------------------------- 1 | package com.yanger.lombok; 2 | 3 | 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import lombok.NonNull; 7 | import lombok.RequiredArgsConstructor; 8 | 9 | @NoArgsConstructor 10 | @RequiredArgsConstructor 11 | @Data 12 | public class Demo { 13 | 14 | @NonNull 15 | private Integer id; 16 | 17 | private String name; 18 | 19 | public static void main(String[] args) { 20 | Demo d = new Demo(1); 21 | d.setName("name"); 22 | System.out.println(d.toString()); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/java/com/yanger/lombok/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | lombok使用参见:https://blog.csdn.net/Simple_Yangger/article/details/90343095 -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/java/com/yanger/mybatis/po/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.mybatis.po; 2 | 3 | public class User { 4 | 5 | private Integer id; 6 | 7 | private String username; 8 | 9 | private String password; 10 | 11 | public Integer getId() { 12 | return id; 13 | } 14 | 15 | public void setId(Integer id) { 16 | this.id = id; 17 | } 18 | 19 | public String getUsername() { 20 | return username; 21 | } 22 | 23 | public void setUsername(String username) { 24 | this.username = username; 25 | } 26 | 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | datasource: 6 | # 新版驱动从com.mysql.jdbc.Driver变更为com.mysql.cj.jdbc.Driver 7 | driver-class-name: com.mysql.cj.jdbc.Driver 8 | # 数据源需要添加时间标准和指定编码格式解决乱码 You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. 9 | url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC 10 | username: root 11 | password: 1234 12 | # jpa: 13 | # show-sql: true 14 | # database-platform: org.hibernate.dialect.MySQL5InnoDBDialect 15 | profiles: 16 | active: dev 17 | 18 | mybatis: 19 | configuration: 20 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 21 | 22 | my: 23 | name: yanger 24 | girl: 25 | name: xiaohong 26 | age: 22 27 | 28 | -------------------------------------------------------------------------------- /p11-springboot-lombok/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p11-springboot-lombok/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p12-springboot-muti-jdbcTemplate/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p12-springboot-muti-jdbcTemplate/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p12-springboot-muti-jdbcTemplate/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p12-springboot-muti-jdbcTemplate/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p12-springboot-muti-jdbcTemplate/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p12-springboot-muti-jdbcTemplate/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p12-springboot-muti-jdbcTemplate/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p12-springboot-muti-jdbcTemplate/src/main/java/com/yanger/devtools/DevtoolsApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.devtools; 2 | 3 | import com.thoughtworks.xstream.XStream; 4 | import com.yanger.swagger2.Book; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController("devtools") 9 | public class DevtoolsApi { 10 | 11 | @GetMapping("msg") 12 | public String getMsg(){ 13 | return "Hello devtools new"; 14 | } 15 | 16 | @GetMapping("cast") 17 | public void cast(){ 18 | String xml = "xstream"; 19 | XStream xstream = new XStream(); 20 | // 指定xtream的classloader,否则会报转换异常 21 | xstream.setClassLoader(Book.class.getClassLoader()); 22 | xstream.alias("book", Book.class); 23 | Book book = (Book)xstream.fromXML(xml); 24 | System.out.print(book.getName()); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /p12-springboot-muti-jdbcTemplate/src/main/java/com/yanger/jdbcTemplate/po/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.jdbcTemplate.po; 2 | 3 | public class User { 4 | 5 | private Integer id; 6 | 7 | private String username; 8 | 9 | private String password; 10 | 11 | public Integer getId() { 12 | return id; 13 | } 14 | 15 | public void setId(Integer id) { 16 | this.id = id; 17 | } 18 | 19 | public String getUsername() { 20 | return username; 21 | } 22 | 23 | public void setUsername(String username) { 24 | this.username = username; 25 | } 26 | 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /p12-springboot-muti-jdbcTemplate/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p12-springboot-muti-jdbcTemplate/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p12-springboot-muti-jdbcTemplate/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p12-springboot-muti-jdbcTemplate/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p12-springboot-muti-jdbcTemplate/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p13-springboot-muti-jpa/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/src/main/java/com/yanger/devtools/DevtoolsApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.devtools; 2 | 3 | import com.thoughtworks.xstream.XStream; 4 | import com.yanger.swagger2.Book; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController("devtools") 9 | public class DevtoolsApi { 10 | 11 | @GetMapping("msg") 12 | public String getMsg(){ 13 | return "Hello devtools new"; 14 | } 15 | 16 | @GetMapping("cast") 17 | public void cast(){ 18 | String xml = "xstream"; 19 | XStream xstream = new XStream(); 20 | // 指定xtream的classloader,否则会报转换异常 21 | xstream.setClassLoader(Book.class.getClassLoader()); 22 | xstream.alias("book", Book.class); 23 | Book book = (Book)xstream.fromXML(xml); 24 | System.out.print(book.getName()); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/src/main/java/com/yanger/jdbcTemplate/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/src/main/java/com/yanger/jpa/dao/IUserDao.java: -------------------------------------------------------------------------------- 1 | package com.yanger.jpa.dao; 2 | 3 | import com.yanger.jpa.po.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | 8 | public interface IUserDao extends JpaRepository { 9 | 10 | /** 11 | * 根据用户名和密码查询,根据方法名来生成实体类 12 | * @param username 13 | * @param password 14 | * @return 15 | */ 16 | User findByUsernameAndPassword(String username, String password); 17 | 18 | /** 19 | * 根据用户名和密码查询 20 | * @param username 21 | * @param password 22 | * @return 23 | */ 24 | @Query(nativeQuery = true, value = "select * from user where username = :username and password = :password") 25 | User find(@Param("username") String username, @Param("password") String password); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/src/main/java/com/yanger/jpa/po/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.jpa.po; 2 | 3 | import javax.persistence.*; 4 | 5 | // 表名关联的表 6 | @Table(name = "user") 7 | @Entity 8 | public class User { 9 | 10 | @Id 11 | @GeneratedValue(strategy = GenerationType.IDENTITY) // 使用数据库的主键自增策略 12 | private Integer id; 13 | 14 | private String username; 15 | 16 | private String password; 17 | 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public String getUsername() { 27 | return username; 28 | } 29 | 30 | public void setUsername(String username) { 31 | this.username = username; 32 | } 33 | 34 | public String getPassword() { 35 | return password; 36 | } 37 | 38 | public void setPassword(String password) { 39 | this.password = password; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/src/main/java/com/yanger/jpa/sdao/ISlaveUserDao.java: -------------------------------------------------------------------------------- 1 | package com.yanger.jpa.sdao; 2 | 3 | import com.yanger.jpa.po.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface ISlaveUserDao extends JpaRepository { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p13-springboot-muti-jpa/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p14-springboot-muti-mybatis/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/src/main/java/com/yanger/devtools/DevtoolsApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.devtools; 2 | 3 | import com.thoughtworks.xstream.XStream; 4 | import com.yanger.swagger2.Book; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController("devtools") 9 | public class DevtoolsApi { 10 | 11 | @GetMapping("msg") 12 | public String getMsg(){ 13 | return "Hello devtools new"; 14 | } 15 | 16 | @GetMapping("cast") 17 | public void cast(){ 18 | String xml = "xstream"; 19 | XStream xstream = new XStream(); 20 | // 指定xtream的classloader,否则会报转换异常 21 | xstream.setClassLoader(Book.class.getClassLoader()); 22 | xstream.alias("book", Book.class); 23 | Book book = (Book)xstream.fromXML(xml); 24 | System.out.print(book.getName()); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/src/main/java/com/yanger/jdbcTemplate/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/src/main/java/com/yanger/jpa/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/src/main/java/com/yanger/mybatis/po/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.mybatis.po; 2 | 3 | public class User { 4 | 5 | private Integer id; 6 | 7 | private String username; 8 | 9 | private String password; 10 | 11 | public Integer getId() { 12 | return id; 13 | } 14 | 15 | public void setId(Integer id) { 16 | this.id = id; 17 | } 18 | 19 | public String getUsername() { 20 | return username; 21 | } 22 | 23 | public void setUsername(String username) { 24 | this.username = username; 25 | } 26 | 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p14-springboot-muti-mybatis/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p15-springboot-muti-aop-mybatis/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 6 | 7 | @SpringBootApplication(exclude = { 8 | DataSourceAutoConfiguration.class 9 | }) 10 | public class SpringbootApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(SpringbootApplication.class, args); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/java/com/yanger/devtools/DevtoolsApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.devtools; 2 | 3 | import com.thoughtworks.xstream.XStream; 4 | import com.yanger.swagger2.Book; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController("devtools") 9 | public class DevtoolsApi { 10 | 11 | @GetMapping("msg") 12 | public String getMsg(){ 13 | return "Hello devtools new"; 14 | } 15 | 16 | @GetMapping("cast") 17 | public void cast(){ 18 | String xml = "xstream"; 19 | XStream xstream = new XStream(); 20 | // 指定xtream的classloader,否则会报转换异常 21 | xstream.setClassLoader(Book.class.getClassLoader()); 22 | xstream.alias("book", Book.class); 23 | Book book = (Book)xstream.fromXML(xml); 24 | System.out.print(book.getName()); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/java/com/yanger/jdbcTemplate/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/java/com/yanger/jpa/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/java/com/yanger/mybatis/po/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.mybatis.po; 2 | 3 | public class User { 4 | 5 | private Integer id; 6 | 7 | private String username; 8 | 9 | private String password; 10 | 11 | public Integer getId() { 12 | return id; 13 | } 14 | 15 | public void setId(Integer id) { 16 | this.id = id; 17 | } 18 | 19 | public String getUsername() { 20 | return username; 21 | } 22 | 23 | public void setUsername(String username) { 24 | this.username = username; 25 | } 26 | 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/java/com/yanger/mybatis/util/DS.java: -------------------------------------------------------------------------------- 1 | package com.yanger.mybatis.util; 2 | 3 | import java.lang.annotation.*; 4 | 5 | @Retention(RetentionPolicy.RUNTIME) 6 | @Target({ElementType.METHOD}) 7 | @Documented 8 | public @interface DS { 9 | 10 | String value() default DataSourceContextHolder.DEFAULT_DATASOURCE; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/java/com/yanger/mybatis/util/DataSourceContextHolder.java: -------------------------------------------------------------------------------- 1 | package com.yanger.mybatis.util; 2 | 3 | public class DataSourceContextHolder { 4 | 5 | // 默认数据源 6 | public static final String DEFAULT_DATASOURCE = "master"; 7 | 8 | private static final ThreadLocal contextHolder = new ThreadLocal<>(); 9 | 10 | // 设置数据源名 11 | public static void setDB(String dbType) { 12 | contextHolder.set(dbType); 13 | } 14 | 15 | // 获取数据源名 16 | public static String getDB() { 17 | return (contextHolder.get()); 18 | } 19 | 20 | // 清除数据源名 21 | public static void clearDB() { 22 | contextHolder.remove(); 23 | } 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/java/com/yanger/mybatis/util/DynamicDataSource.java: -------------------------------------------------------------------------------- 1 | package com.yanger.mybatis.util; 2 | 3 | import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; 4 | import org.springframework.util.StringUtils; 5 | 6 | public class DynamicDataSource extends AbstractRoutingDataSource { 7 | 8 | @Override 9 | protected Object determineCurrentLookupKey() { 10 | System.out.println("数据源为" + DataSourceContextHolder.getDB()); 11 | return DataSourceContextHolder.getDB(); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p15-springboot-muti-aop-mybatis/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p16-springboot-mybatis-sharding/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 6 | 7 | @SpringBootApplication(exclude = { 8 | DataSourceAutoConfiguration.class 9 | }) 10 | public class SpringbootApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(SpringbootApplication.class, args); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/src/main/java/com/yanger/devtools/DevtoolsApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.devtools; 2 | 3 | import com.thoughtworks.xstream.XStream; 4 | import com.yanger.swagger2.Book; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController("devtools") 9 | public class DevtoolsApi { 10 | 11 | @GetMapping("msg") 12 | public String getMsg(){ 13 | return "Hello devtools new"; 14 | } 15 | 16 | @GetMapping("cast") 17 | public void cast(){ 18 | String xml = "xstream"; 19 | XStream xstream = new XStream(); 20 | // 指定xtream的classloader,否则会报转换异常 21 | xstream.setClassLoader(Book.class.getClassLoader()); 22 | xstream.alias("book", Book.class); 23 | Book book = (Book)xstream.fromXML(xml); 24 | System.out.print(book.getName()); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/src/main/java/com/yanger/jdbcTemplate/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/src/main/java/com/yanger/jpa/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/src/main/java/com/yanger/mybatis/po/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.mybatis.po; 2 | 3 | public class User { 4 | 5 | private Integer id; 6 | 7 | private String username; 8 | 9 | private String password; 10 | 11 | public Integer getId() { 12 | return id; 13 | } 14 | 15 | public void setId(Integer id) { 16 | this.id = id; 17 | } 18 | 19 | public String getUsername() { 20 | return username; 21 | } 22 | 23 | public void setUsername(String username) { 24 | this.username = username; 25 | } 26 | 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | 5 | my: 6 | name: yanger 7 | girl: 8 | name: xiaohong 9 | age: 22 10 | -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | 8 | mybatis: 9 | configuration: 10 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 11 | 12 | sharding: 13 | jdbc: 14 | datasource: 15 | names: master,slave 16 | master: 17 | type: com.alibaba.druid.pool.DruidDataSource 18 | driver-class-name: com.mysql.cj.jdbc.Driver 19 | url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC 20 | username: root 21 | password: 1234 22 | slave: 23 | type: com.alibaba.druid.pool.DruidDataSource 24 | driver-class-name: com.mysql.cj.jdbc.Driver 25 | url: jdbc:mysql://localhost:3306/springboot2?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC 26 | username: root 27 | password: 1234 28 | 29 | -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p16-springboot-mybatis-sharding/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p17-springboot-jsp/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p17-springboot-jsp/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p17-springboot-jsp/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p17-springboot-jsp/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p17-springboot-jsp/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p17-springboot-jsp/src/main/java/com/yanger/jsp/IndexApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.jsp; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | /** 8 | * Created by Administrator on 2019/10/11. 9 | */ 10 | @Controller 11 | @RequestMapping("index") 12 | public class IndexApi { 13 | 14 | @RequestMapping("/hello") 15 | public String hello(){ 16 | return "hello"; 17 | } 18 | 19 | @RequestMapping("/mv") 20 | public ModelAndView mv(){ 21 | ModelAndView mv = new ModelAndView("mv"); 22 | mv.addObject("name","yanger"); 23 | return mv; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /p17-springboot-jsp/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p17-springboot-jsp/src/main/java/com/yanger/swagger2/Book.java: -------------------------------------------------------------------------------- 1 | package com.yanger.swagger2; 2 | 3 | public class Book { 4 | 5 | private String name; 6 | 7 | private String author; 8 | 9 | private Float price; 10 | 11 | public Book(){ 12 | 13 | } 14 | 15 | public Book(String name, String author, Float price) { 16 | this.name = name; 17 | this.author = author; 18 | this.price = price; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | public String getAuthor() { 30 | return author; 31 | } 32 | 33 | public void setAuthor(String author) { 34 | this.author = author; 35 | } 36 | 37 | public Float getPrice() { 38 | return price; 39 | } 40 | 41 | public void setPrice(Float price) { 42 | this.price = price; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /p17-springboot-jsp/src/main/resources/META-INF/resources/pages/hello.jsp: -------------------------------------------------------------------------------- 1 |

hello jsp

-------------------------------------------------------------------------------- /p17-springboot-jsp/src/main/resources/META-INF/resources/pages/mv.jsp: -------------------------------------------------------------------------------- 1 |

hello jsp

2 | I'm ${name} from mv method -------------------------------------------------------------------------------- /p17-springboot-jsp/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p17-springboot-jsp/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p17-springboot-jsp/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | mvc: 8 | view: 9 | prefix: /templates/ #view视图文件(jsp)文件的存储位置,不能直接放在resources目录下,需要放在webapp目录下 10 | #prefix: /pages/ #或者resources下创建META-INF/resources目录 11 | suffix: .jsp #视图文件后缀 12 | -------------------------------------------------------------------------------- /p17-springboot-jsp/src/main/webapp/templates/hello.jsp: -------------------------------------------------------------------------------- 1 | <%--编码格式,防止中心乱码--%> 2 | <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> 3 |

hello jsp

-------------------------------------------------------------------------------- /p17-springboot-jsp/src/main/webapp/templates/mv.jsp: -------------------------------------------------------------------------------- 1 | <%--编码格式,防止中心乱码--%> 2 | <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> 3 |

mv jsp

4 | I'm ${name} from mv method -------------------------------------------------------------------------------- /p17-springboot-jsp/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p18-springboot-thymeleaf/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p18-springboot-thymeleaf/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p18-springboot-thymeleaf/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p18-springboot-thymeleaf/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p18-springboot-thymeleaf/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p18-springboot-thymeleaf/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p18-springboot-thymeleaf/src/main/java/com/yanger/thymeleaf/IndexApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.thymeleaf; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | /** 8 | * Created by Administrator on 2019/10/11. 9 | */ 10 | @Controller 11 | @RequestMapping("index") 12 | public class IndexApi { 13 | 14 | @RequestMapping("/hello") 15 | public String hello(){ 16 | return "hello"; 17 | } 18 | 19 | @RequestMapping("/mv") 20 | public ModelAndView mv(){ 21 | ModelAndView mv = new ModelAndView("mv"); 22 | mv.addObject("name","yanger"); 23 | return mv; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /p18-springboot-thymeleaf/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p18-springboot-thymeleaf/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p18-springboot-thymeleaf/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | thymeleaf: 8 | prefix: classpath:/templates/ 9 | check-template-location: true #是否检查模板位置是否存在 10 | suffix: .html 11 | encoding: utf-8 #模板编码 12 | servlet: 13 | content-type: text/html 14 | mode: HTML5 15 | cache: false #禁用缓存,本地开发设置为false,避免修改后重启服务器 -------------------------------------------------------------------------------- /p18-springboot-thymeleaf/src/main/resources/templates/hello.html: -------------------------------------------------------------------------------- 1 |

hello thymeleaf

-------------------------------------------------------------------------------- /p18-springboot-thymeleaf/src/main/resources/templates/mv.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

mv thymeleaf

4 | I'm from mv method 5 | -------------------------------------------------------------------------------- /p18-springboot-thymeleaf/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p19-springboot-freemarker/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p19-springboot-freemarker/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p19-springboot-freemarker/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p19-springboot-freemarker/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p19-springboot-freemarker/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p19-springboot-freemarker/src/main/java/com/yanger/freemarker/IndexApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.freemarker; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | /** 8 | * Created by Administrator on 2019/10/11. 9 | */ 10 | @Controller 11 | @RequestMapping("index") 12 | public class IndexApi { 13 | 14 | @RequestMapping("/hello") 15 | public String hello(){ 16 | return "hello"; 17 | } 18 | 19 | @RequestMapping("/mv") 20 | public ModelAndView mv(){ 21 | ModelAndView mv = new ModelAndView("mv"); 22 | mv.addObject("name","yanger"); 23 | return mv; 24 | } 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /p19-springboot-freemarker/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p19-springboot-freemarker/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p19-springboot-freemarker/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p19-springboot-freemarker/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | freemarker: 8 | enabled: true #是否启用freemarker 9 | template-loader-path: classpath:/templates/ #设定模板的加载路径,多个以逗号分隔 10 | suffix: .ftl #设定模板的后缀 11 | content-type: text/html 12 | check-template-location: true #是否检查模板位置是否存在 13 | cache: false #是否启用模板缓存 14 | charset: UTF-8 #模板编码 15 | #一些常用配置 16 | allow-request-override: false #是否允许HttpServletRequest属性覆盖(隐藏)控制器生成的同名模型属性 17 | allow-session-override: false #是否允许HttpSession属性覆盖(隐藏)控制器生成的同名模型属性 18 | expose-request-attributes: false #设定所有request的属性在merge到模板的时候,是否要都添加到model中 19 | expose-session-attributes: false #是否在merge模板的时候,将HttpSession属性都添加到model中 20 | expose-spring-macro-helpers: true #设定是否以springMacroRequestContext的形式暴露RequestContext给Spring’s macro library使用 21 | prefer-file-system-access: true #是否优先从文件系统加载template,以支持热加载,默认为true -------------------------------------------------------------------------------- /p19-springboot-freemarker/src/main/resources/templates/hello.ftl: -------------------------------------------------------------------------------- 1 |

hello freemarker

-------------------------------------------------------------------------------- /p19-springboot-freemarker/src/main/resources/templates/mv.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 |

mv freemarker

4 | I'm ${name} from mv method 5 | -------------------------------------------------------------------------------- /p19-springboot-freemarker/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p2-springboot-config/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p2-springboot-config/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p2-springboot-config/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p2-springboot-config/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p2-springboot-config/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p2-springboot-config/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p2-springboot-config/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p2-springboot-config/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p2-springboot-config/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p2-springboot-config/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p2-springboot-config/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | 8 | my: 9 | name: yanger 10 | girl: 11 | name: xiaohong 12 | age: 22 13 | 14 | -------------------------------------------------------------------------------- /p2-springboot-config/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p2-springboot-config/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p20-springboot-cache/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p20-springboot-cache/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p20-springboot-cache/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p20-springboot-cache/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p20-springboot-cache/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cache.annotation.EnableCaching; 6 | 7 | @EnableCaching //开启缓存 8 | @SpringBootApplication 9 | public class SpringbootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringbootApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /p20-springboot-cache/src/main/java/com/yanger/cache/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.cache; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author yanger 8 | * @description 数据模型 9 | * @date 2019/10/12 10 | */ 11 | @Data 12 | @AllArgsConstructor 13 | public class User { 14 | 15 | private String code; 16 | 17 | private String name; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /p20-springboot-cache/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p20-springboot-cache/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p20-springboot-cache/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p20-springboot-cache/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev -------------------------------------------------------------------------------- /p20-springboot-cache/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p21-springboot-cache-redis/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p21-springboot-cache-redis/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p21-springboot-cache-redis/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p21-springboot-cache-redis/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p21-springboot-cache-redis/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p21-springboot-cache-redis/src/main/java/com/yanger/cache/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.cache; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @author yanger 10 | * @description 数据模型 11 | * @date 2019/10/12 12 | */ 13 | @Data 14 | @AllArgsConstructor 15 | public class User implements Serializable { 16 | 17 | private String code; 18 | 19 | private String name; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /p21-springboot-cache-redis/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p21-springboot-cache-redis/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p21-springboot-cache-redis/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p21-springboot-cache-redis/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | redis: 8 | host: localhost #redis服务器地址 9 | port: 6379 #redis端口 10 | password: 1234 #redis密码 11 | timeout: 60000 #连接超时时间 12 | database: 0 #数据库索引,默认为0 13 | 14 | -------------------------------------------------------------------------------- /p21-springboot-cache-redis/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p22-springboot-cache-ehcache/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p22-springboot-cache-ehcache/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p22-springboot-cache-ehcache/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p22-springboot-cache-ehcache/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p22-springboot-cache-ehcache/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cache.annotation.EnableCaching; 6 | 7 | @EnableCaching 8 | @SpringBootApplication 9 | public class SpringbootApplication { 10 | 11 | public static void main(String[] args) { 12 | String tmpDir = System.getProperty("java.io.tmpdir"); 13 | System.out.println("临时路径:" + tmpDir); 14 | SpringApplication.run(SpringbootApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /p22-springboot-cache-ehcache/src/main/java/com/yanger/cache/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.cache; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @author yanger 10 | * @description 数据模型 11 | * @date 2019/10/12 12 | */ 13 | @Data 14 | @AllArgsConstructor 15 | public class User implements Serializable { 16 | 17 | private String code; 18 | 19 | private String name; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /p22-springboot-cache-ehcache/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p22-springboot-cache-ehcache/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p22-springboot-cache-ehcache/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p22-springboot-cache-ehcache/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | cache: 8 | type: ehcache 9 | ehcache: 10 | config: classpath:/ehcache.xml -------------------------------------------------------------------------------- /p22-springboot-cache-ehcache/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p23-springboot-async/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p23-springboot-async/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p23-springboot-async/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p23-springboot-async/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p23-springboot-async/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableAsync; 6 | 7 | @EnableAsync 8 | @SpringBootApplication 9 | public class SpringbootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringbootApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /p23-springboot-async/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p23-springboot-async/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p23-springboot-async/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p23-springboot-async/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev -------------------------------------------------------------------------------- /p23-springboot-async/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p24-springboot-schedule/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p24-springboot-schedule/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p24-springboot-schedule/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p24-springboot-schedule/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p24-springboot-schedule/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p24-springboot-schedule/src/main/java/com/yanger/schedule/Task.java: -------------------------------------------------------------------------------- 1 | package com.yanger.schedule; 2 | 3 | import org.springframework.scheduling.annotation.EnableScheduling; 4 | import org.springframework.scheduling.annotation.Scheduled; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | 10 | /** 11 | * @author yanger 12 | * @description 定时任务执行类 13 | * @date 2019/10/15 14 | */ 15 | @EnableScheduling 16 | @Component 17 | public class Task { 18 | 19 | private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); 20 | 21 | @Scheduled(fixedRate = 1000) 22 | public void taskOne(){ 23 | System.out.println("现在时间:" + dateFormat.format(new Date())); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /p24-springboot-schedule/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p24-springboot-schedule/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p24-springboot-schedule/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p24-springboot-schedule/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev -------------------------------------------------------------------------------- /p24-springboot-schedule/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p25-springboot-quartz/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p25-springboot-quartz/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p25-springboot-quartz/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p25-springboot-quartz/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p25-springboot-quartz/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p25-springboot-quartz/src/main/java/com/yanger/quartz/QuartzJob1.java: -------------------------------------------------------------------------------- 1 | package com.yanger.quartz; 2 | 3 | import org.quartz.JobExecutionContext; 4 | import org.quartz.JobExecutionException; 5 | import org.springframework.scheduling.quartz.QuartzJobBean; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | 10 | /** 11 | * @author yanger 12 | * @description 定时任务一 13 | * @date 2019/10/16 14 | */ 15 | public class QuartzJob1 extends QuartzJobBean { 16 | 17 | @Override 18 | protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException { 19 | SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 20 | System.out.println("QuartzJob1----" + sdf.format(new Date())); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /p25-springboot-quartz/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p25-springboot-quartz/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p25-springboot-quartz/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p25-springboot-quartz/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p26-springboot-exception/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p26-springboot-exception/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p26-springboot-exception/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p26-springboot-exception/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p26-springboot-exception/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p26-springboot-exception/src/main/java/com/yanger/exception/AuthException.java: -------------------------------------------------------------------------------- 1 | package com.yanger.exception; 2 | 3 | /** 4 | * @author yanger 5 | * @description 权限异常 6 | * @date 2019/10/17 7 | */ 8 | public class AuthException extends Exception { 9 | 10 | public AuthException(String msg) { 11 | super(msg); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /p26-springboot-exception/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p26-springboot-exception/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p26-springboot-exception/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p26-springboot-exception/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | mvc: 8 | view: 9 | prefix: /templates/ #view视图文件(jsp)文件的存储位置,不能直接放在resources目录下,需要放在webapp目录下 10 | suffix: .jsp #视图文件后缀 -------------------------------------------------------------------------------- /p26-springboot-exception/src/main/webapp/templates/error.jsp: -------------------------------------------------------------------------------- 1 | 2 | <%--编码格式,防止中心乱码--%> 3 | <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> 4 | 5 |

Error Page

6 |

${msg}

7 | 8 | 9 | -------------------------------------------------------------------------------- /p26-springboot-exception/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p27-springboot-log4j/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p27-springboot-log4j/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p27-springboot-log4j/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p27-springboot-log4j/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p27-springboot-log4j/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p27-springboot-log4j/src/main/java/com/yanger/log/LogApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.log; 2 | 3 | import lombok.extern.log4j.Log4j; 4 | import lombok.extern.log4j.Log4j2; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | /** 11 | * @author yanger 12 | * @description 测试日志输出 13 | * @date 2019/10/17 14 | */ 15 | @Slf4j 16 | @RestController 17 | @RequestMapping("log") 18 | public class LogApi { 19 | 20 | @GetMapping("print") 21 | public void print(){ 22 | log.error("-------------------error日志打印" ); 23 | log.warn("-------------------warn日志打印"); 24 | log.info("-------------------info日志打印"); 25 | log.debug("-------------------debug日志打印"); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /p27-springboot-log4j/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p27-springboot-log4j/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p27-springboot-log4j/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p27-springboot-log4j/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | 8 | #og4j 2.x版本不再支持像1.x中的.properties后缀的文件配置方式,2.x版本配置文件后缀名只能为".xml",".json"或者".jsn". 9 | logging: 10 | config: classpath:log4j2.xml 11 | -------------------------------------------------------------------------------- /p27-springboot-log4j/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p28-springboot-actuator/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p28-springboot-actuator/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p28-springboot-actuator/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p28-springboot-actuator/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p28-springboot-actuator/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p28-springboot-actuator/src/main/java/com/yanger/actuator/ActuatorApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.actuator; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * @author yanger 8 | * @description 9 | * @date 2019/11/5 10 | */ 11 | @RequestMapping("actuator") 12 | @RestController 13 | public class ActuatorApi { 14 | 15 | @RequestMapping("hello") 16 | public String Hello() { 17 | return "Hello actuator"; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /p28-springboot-actuator/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p28-springboot-actuator/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p28-springboot-actuator/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p28-springboot-actuator/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | 8 | management: 9 | endpoint: 10 | health: 11 | enabled: true 12 | endpoints: 13 | web: 14 | exposure: 15 | include: '*' 16 | -------------------------------------------------------------------------------- /p28-springboot-actuator/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p29-springboot-admin/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p29-springboot-admin/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p29-springboot-admin/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p29-springboot-admin/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p29-springboot-admin/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import de.codecentric.boot.admin.server.config.EnableAdminServer; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableAdminServer 9 | public class SpringbootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringbootApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /p29-springboot-admin/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p29-springboot-admin/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p29-springboot-admin/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p29-springboot-admin/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | boot: 8 | admin: 9 | client: 10 | url: http://localhost:10900/ 11 | auto-registration: true 12 | instance: 13 | name: spring boot admin 14 | security: 15 | user: 16 | name: "admin" 17 | password: "admin" 18 | 19 | management: 20 | endpoints: 21 | web: 22 | exposure: 23 | include: '*' 24 | -------------------------------------------------------------------------------- /p29-springboot-admin/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p3-springboot-swagger2/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p3-springboot-swagger2/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p3-springboot-swagger2/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p3-springboot-swagger2/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p3-springboot-swagger2/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p3-springboot-swagger2/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p3-springboot-swagger2/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p3-springboot-swagger2/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p3-springboot-swagger2/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p3-springboot-swagger2/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p3-springboot-swagger2/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | 8 | my: 9 | name: yanger 10 | girl: 11 | name: xiaohong 12 | age: 22 13 | 14 | -------------------------------------------------------------------------------- /p3-springboot-swagger2/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p3-springboot-swagger2/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p30-springboot-restTemplate/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p30-springboot-restTemplate/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p30-springboot-restTemplate/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p30-springboot-restTemplate/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p30-springboot-restTemplate/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p30-springboot-restTemplate/src/main/java/com/yanger/rest/RestConfig.java: -------------------------------------------------------------------------------- 1 | package com.yanger.rest; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.client.RestTemplate; 6 | 7 | /** 8 | * @author yanger 9 | * @description restTemplate配置类 10 | * @date 2019/11/6 11 | */ 12 | @Configuration 13 | public class RestConfig { 14 | 15 | @Bean 16 | public RestTemplate restTemplate() { 17 | return new RestTemplate(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /p30-springboot-restTemplate/src/main/java/com/yanger/rest/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.rest; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author yanger 11 | * @description 12 | * @date 2019/11/6 13 | */ 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | public class User implements Serializable { 18 | 19 | private String name; 20 | 21 | private Integer age; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /p30-springboot-restTemplate/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p30-springboot-restTemplate/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p30-springboot-restTemplate/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p30-springboot-restTemplate/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev -------------------------------------------------------------------------------- /p30-springboot-restTemplate/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p31-springboot-fileupload/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p31-springboot-fileupload/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p31-springboot-fileupload/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p31-springboot-fileupload/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p31-springboot-fileupload/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p31-springboot-fileupload/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p31-springboot-fileupload/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p31-springboot-fileupload/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p31-springboot-fileupload/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev -------------------------------------------------------------------------------- /p31-springboot-fileupload/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p32-springboot-mail/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p32-springboot-mail/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p32-springboot-mail/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p32-springboot-mail/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p32-springboot-mail/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p32-springboot-mail/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p32-springboot-mail/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p32-springboot-mail/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p32-springboot-mail/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev -------------------------------------------------------------------------------- /p32-springboot-mail/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p33-springboot-validation/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p33-springboot-validation/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p33-springboot-validation/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p33-springboot-validation/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p33-springboot-validation/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p33-springboot-validation/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p33-springboot-validation/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p33-springboot-validation/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p33-springboot-validation/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev -------------------------------------------------------------------------------- /p33-springboot-validation/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p34-springboot-xml/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p34-springboot-xml/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p34-springboot-xml/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p34-springboot-xml/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p34-springboot-xml/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p34-springboot-xml/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p34-springboot-xml/src/main/java/com/yanger/swagger2/Book.java: -------------------------------------------------------------------------------- 1 | package com.yanger.swagger2; 2 | 3 | public class Book { 4 | 5 | private String name; 6 | 7 | private String author; 8 | 9 | private Float price; 10 | 11 | public Book(){ 12 | 13 | } 14 | 15 | public Book(String name, String author, Float price) { 16 | this.name = name; 17 | this.author = author; 18 | this.price = price; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | public String getAuthor() { 30 | return author; 31 | } 32 | 33 | public void setAuthor(String author) { 34 | this.author = author; 35 | } 36 | 37 | public Float getPrice() { 38 | return price; 39 | } 40 | 41 | public void setPrice(Float price) { 42 | this.price = price; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /p34-springboot-xml/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p34-springboot-xml/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p34-springboot-xml/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev -------------------------------------------------------------------------------- /p34-springboot-xml/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p4-springboot-devtools/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p4-springboot-devtools/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p4-springboot-devtools/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p4-springboot-devtools/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p4-springboot-devtools/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p4-springboot-devtools/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p4-springboot-devtools/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p4-springboot-devtools/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p4-springboot-devtools/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p4-springboot-devtools/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p4-springboot-devtools/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | 8 | my: 9 | name: yanger 10 | girl: 11 | name: xiaohong 12 | age: 22 13 | 14 | -------------------------------------------------------------------------------- /p4-springboot-devtools/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p4-springboot-devtools/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p5-springboot-jdbcTemplate/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/src/main/java/com/yanger/devtools/DevtoolsApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.devtools; 2 | 3 | import com.thoughtworks.xstream.XStream; 4 | import com.yanger.swagger2.Book; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController("devtools") 9 | public class DevtoolsApi { 10 | 11 | @GetMapping("msg") 12 | public String getMsg(){ 13 | return "Hello devtools new"; 14 | } 15 | 16 | @GetMapping("cast") 17 | public void cast(){ 18 | String xml = "xstream"; 19 | XStream xstream = new XStream(); 20 | // 指定xtream的classloader,否则会报转换异常 21 | xstream.setClassLoader(Book.class.getClassLoader()); 22 | xstream.alias("book", Book.class); 23 | Book book = (Book)xstream.fromXML(xml); 24 | System.out.print(book.getName()); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/src/main/java/com/yanger/jdbcTemplate/dao/IUserDao.java: -------------------------------------------------------------------------------- 1 | package com.yanger.jdbcTemplate.dao; 2 | 3 | import com.yanger.jdbcTemplate.po.User; 4 | 5 | import java.util.List; 6 | 7 | public interface IUserDao { 8 | 9 | /** 10 | * 添加用户 11 | * @param user 12 | * @return 13 | */ 14 | int add(User user); 15 | 16 | /** 17 | * 根据id删除用户 18 | * @param id 19 | * @return 20 | */ 21 | int del(int id); 22 | 23 | /** 24 | * 更新用户信息 25 | * @param user 26 | * @return 27 | */ 28 | int update(User user); 29 | 30 | /** 31 | * 根据id查找用户 32 | * @param id 33 | * @return 34 | */ 35 | User find(int id); 36 | 37 | /** 38 | * 获取全部用户 39 | * @return 40 | */ 41 | List findAll(); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/src/main/java/com/yanger/jdbcTemplate/po/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.jdbcTemplate.po; 2 | 3 | public class User { 4 | 5 | private Integer id; 6 | 7 | private String username; 8 | 9 | private String password; 10 | 11 | public Integer getId() { 12 | return id; 13 | } 14 | 15 | public void setId(Integer id) { 16 | this.id = id; 17 | } 18 | 19 | public String getUsername() { 20 | return username; 21 | } 22 | 23 | public void setUsername(String username) { 24 | this.username = username; 25 | } 26 | 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | datasource: 6 | # 新版驱动从com.mysql.jdbc.Driver变更为com.mysql.cj.jdbc.Driver 7 | driver-class-name: com.mysql.cj.jdbc.Driver 8 | # 数据源需要添加时间标准和指定编码格式解决乱码 You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. 9 | url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC 10 | username: root 11 | password: 1234 12 | profiles: 13 | active: dev 14 | 15 | my: 16 | name: yanger 17 | girl: 18 | name: xiaohong 19 | age: 22 20 | 21 | -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p5-springboot-jdbcTemplate/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p6-springboot-jpa/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p6-springboot-jpa/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p6-springboot-jpa/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p6-springboot-jpa/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p6-springboot-jpa/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p6-springboot-jpa/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p6-springboot-jpa/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p6-springboot-jpa/src/main/java/com/yanger/devtools/DevtoolsApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.devtools; 2 | 3 | import com.thoughtworks.xstream.XStream; 4 | import com.yanger.swagger2.Book; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController("devtools") 9 | public class DevtoolsApi { 10 | 11 | @GetMapping("msg") 12 | public String getMsg(){ 13 | return "Hello devtools new"; 14 | } 15 | 16 | @GetMapping("cast") 17 | public void cast(){ 18 | String xml = "xstream"; 19 | XStream xstream = new XStream(); 20 | // 指定xtream的classloader,否则会报转换异常 21 | xstream.setClassLoader(Book.class.getClassLoader()); 22 | xstream.alias("book", Book.class); 23 | Book book = (Book)xstream.fromXML(xml); 24 | System.out.print(book.getName()); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /p6-springboot-jpa/src/main/java/com/yanger/jdbcTemplate/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p6-springboot-jpa/src/main/java/com/yanger/jpa/dao/IUserDao.java: -------------------------------------------------------------------------------- 1 | package com.yanger.jpa.dao; 2 | 3 | import com.yanger.jpa.po.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | 8 | public interface IUserDao extends JpaRepository { 9 | 10 | /** 11 | * 根据用户名和密码查询,根据方法名来生成实体类 12 | * @param username 13 | * @param password 14 | * @return 15 | */ 16 | User findByUsernameAndPassword(String username, String password); 17 | 18 | /** 19 | * 根据用户名和密码查询 20 | * @param username 21 | * @param password 22 | * @return 23 | */ 24 | @Query(nativeQuery = true, value = "select * from user where username = :username and password = :password") 25 | User find(@Param("username") String username, @Param("password") String password); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /p6-springboot-jpa/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p6-springboot-jpa/src/main/java/com/yanger/swagger2/Book.java: -------------------------------------------------------------------------------- 1 | package com.yanger.swagger2; 2 | 3 | public class Book { 4 | 5 | private String name; 6 | 7 | private String author; 8 | 9 | private Float price; 10 | 11 | public Book(){ 12 | 13 | } 14 | 15 | public Book(String name, String author, Float price) { 16 | this.name = name; 17 | this.author = author; 18 | this.price = price; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | public String getAuthor() { 30 | return author; 31 | } 32 | 33 | public void setAuthor(String author) { 34 | this.author = author; 35 | } 36 | 37 | public Float getPrice() { 38 | return price; 39 | } 40 | 41 | public void setPrice(Float price) { 42 | this.price = price; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /p6-springboot-jpa/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p6-springboot-jpa/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p6-springboot-jpa/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | datasource: 6 | # 新版驱动从com.mysql.jdbc.Driver变更为com.mysql.cj.jdbc.Driver 7 | driver-class-name: com.mysql.cj.jdbc.Driver 8 | # 数据源需要添加时间标准和指定编码格式解决乱码 You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. 9 | url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC 10 | username: root 11 | password: 1234 12 | jpa: 13 | show-sql: true 14 | # 配置jpa数据库类型 15 | database-platform: org.hibernate.dialect.MySQL5InnoDBDialect 16 | profiles: 17 | active: dev 18 | 19 | my: 20 | name: yanger 21 | girl: 22 | name: xiaohong 23 | age: 22 24 | 25 | -------------------------------------------------------------------------------- /p6-springboot-jpa/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p6-springboot-jpa/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p7-springboot-mybatis/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p7-springboot-mybatis/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p7-springboot-mybatis/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p7-springboot-mybatis/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p7-springboot-mybatis/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @MapperScan("com.yanger.*.dao") 8 | @SpringBootApplication 9 | public class SpringbootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringbootApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /p7-springboot-mybatis/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p7-springboot-mybatis/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p7-springboot-mybatis/src/main/java/com/yanger/devtools/DevtoolsApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.devtools; 2 | 3 | import com.thoughtworks.xstream.XStream; 4 | import com.yanger.swagger2.Book; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController("devtools") 9 | public class DevtoolsApi { 10 | 11 | @GetMapping("msg") 12 | public String getMsg(){ 13 | return "Hello devtools new"; 14 | } 15 | 16 | @GetMapping("cast") 17 | public void cast(){ 18 | String xml = "xstream"; 19 | XStream xstream = new XStream(); 20 | // 指定xtream的classloader,否则会报转换异常 21 | xstream.setClassLoader(Book.class.getClassLoader()); 22 | xstream.alias("book", Book.class); 23 | Book book = (Book)xstream.fromXML(xml); 24 | System.out.print(book.getName()); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /p7-springboot-mybatis/src/main/java/com/yanger/jdbcTemplate/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p7-springboot-mybatis/src/main/java/com/yanger/jpa/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p7-springboot-mybatis/src/main/java/com/yanger/mybatis/po/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.mybatis.po; 2 | 3 | public class User { 4 | 5 | private Integer id; 6 | 7 | private String username; 8 | 9 | private String password; 10 | 11 | public Integer getId() { 12 | return id; 13 | } 14 | 15 | public void setId(Integer id) { 16 | this.id = id; 17 | } 18 | 19 | public String getUsername() { 20 | return username; 21 | } 22 | 23 | public void setUsername(String username) { 24 | this.username = username; 25 | } 26 | 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /p7-springboot-mybatis/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p7-springboot-mybatis/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p7-springboot-mybatis/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p7-springboot-mybatis/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10900 3 | 4 | spring: 5 | datasource: 6 | # 新版驱动从com.mysql.jdbc.Driver变更为com.mysql.cj.jdbc.Driver 7 | driver-class-name: com.mysql.cj.jdbc.Driver 8 | # 数据源需要添加时间标准和指定编码格式解决乱码 You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. 9 | url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC 10 | username: root 11 | password: 1234 12 | # jpa: 13 | # show-sql: true 14 | # database-platform: org.hibernate.dialect.MySQL5InnoDBDialect 15 | profiles: 16 | active: dev 17 | 18 | mybatis: 19 | configuration: 20 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 21 | 22 | my: 23 | name: yanger 24 | girl: 25 | name: xiaohong 26 | age: 22 27 | 28 | -------------------------------------------------------------------------------- /p7-springboot-mybatis/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p7-springboot-mybatis/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p8-springboot-mybatis-xml/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/src/main/java/com/yanger/devtools/DevtoolsApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.devtools; 2 | 3 | import com.thoughtworks.xstream.XStream; 4 | import com.yanger.swagger2.Book; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController("devtools") 9 | public class DevtoolsApi { 10 | 11 | @GetMapping("msg") 12 | public String getMsg(){ 13 | return "Hello devtools new"; 14 | } 15 | 16 | @GetMapping("cast") 17 | public void cast(){ 18 | String xml = "xstream"; 19 | XStream xstream = new XStream(); 20 | // 指定xtream的classloader,否则会报转换异常 21 | xstream.setClassLoader(Book.class.getClassLoader()); 22 | xstream.alias("book", Book.class); 23 | Book book = (Book)xstream.fromXML(xml); 24 | System.out.print(book.getName()); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/src/main/java/com/yanger/jdbcTemplate/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/src/main/java/com/yanger/jpa/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/src/main/java/com/yanger/mybatis/po/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.mybatis.po; 2 | 3 | public class User { 4 | 5 | private Integer id; 6 | 7 | private String username; 8 | 9 | private String password; 10 | 11 | public Integer getId() { 12 | return id; 13 | } 14 | 15 | public void setId(Integer id) { 16 | this.id = id; 17 | } 18 | 19 | public String getUsername() { 20 | return username; 21 | } 22 | 23 | public void setUsername(String username) { 24 | this.username = username; 25 | } 26 | 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p8-springboot-mybatis-xml/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /p9-springboot-transaction/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /p9-springboot-transaction/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyanger/springboot-project/a67ea8a906bd664a42c64ea87cb23143ebf9837e/p9-springboot-transaction/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /p9-springboot-transaction/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /p9-springboot-transaction/src/main/java/com/yanger/SpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /p9-springboot-transaction/src/main/java/com/yanger/config/Boy.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Configuration 9 | @PropertySource(value = "classpath:config/config.properties") 10 | @ConfigurationProperties(prefix = "boy") 11 | public class Boy { 12 | 13 | private String name; 14 | 15 | private int age; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /p9-springboot-transaction/src/main/java/com/yanger/config/Girl.java: -------------------------------------------------------------------------------- 1 | package com.yanger.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "my.girl") 8 | public class Girl { 9 | 10 | private String name; 11 | 12 | private int age; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | 26 | public void setAge(int age) { 27 | this.age = age; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /p9-springboot-transaction/src/main/java/com/yanger/devtools/DevtoolsApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.devtools; 2 | 3 | import com.thoughtworks.xstream.XStream; 4 | import com.yanger.swagger2.Book; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController("devtools") 9 | public class DevtoolsApi { 10 | 11 | @GetMapping("msg") 12 | public String getMsg(){ 13 | return "Hello devtools new"; 14 | } 15 | 16 | @GetMapping("cast") 17 | public void cast(){ 18 | String xml = "xstream"; 19 | XStream xstream = new XStream(); 20 | // 指定xtream的classloader,否则会报转换异常 21 | xstream.setClassLoader(Book.class.getClassLoader()); 22 | xstream.alias("book", Book.class); 23 | Book book = (Book)xstream.fromXML(xml); 24 | System.out.print(book.getName()); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /p9-springboot-transaction/src/main/java/com/yanger/jdbcTemplate/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p9-springboot-transaction/src/main/java/com/yanger/jpa/description.txt: -------------------------------------------------------------------------------- 1 | 说明: 2 | 操作数据库的dao层,一般一个项目(或者说一个模块)只会使用一种方式,所以演示中只保留一种方式。 -------------------------------------------------------------------------------- /p9-springboot-transaction/src/main/java/com/yanger/mybatis/po/User.java: -------------------------------------------------------------------------------- 1 | package com.yanger.mybatis.po; 2 | 3 | public class User { 4 | 5 | private Integer id; 6 | 7 | private String username; 8 | 9 | private String password; 10 | 11 | public Integer getId() { 12 | return id; 13 | } 14 | 15 | public void setId(Integer id) { 16 | this.id = id; 17 | } 18 | 19 | public String getUsername() { 20 | return username; 21 | } 22 | 23 | public void setUsername(String username) { 24 | this.username = username; 25 | } 26 | 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /p9-springboot-transaction/src/main/java/com/yanger/start/HelloApi.java: -------------------------------------------------------------------------------- 1 | package com.yanger.start; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloApi { 8 | 9 | @GetMapping("hello") 10 | public String hello(){ 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /p9-springboot-transaction/src/main/java/com/yanger/transaction/dao/TransactionDao.java: -------------------------------------------------------------------------------- 1 | package com.yanger.transaction.dao; 2 | 3 | import com.yanger.mybatis.po.User; 4 | import org.apache.ibatis.annotations.Insert; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | import org.apache.ibatis.annotations.Select; 8 | 9 | @Mapper 10 | public interface TransactionDao { 11 | 12 | @Insert("insert into user(username, password) values(#{username}, #{password})") 13 | void insert(User user); 14 | 15 | @Select("select * from user where username = #{username}") 16 | User findByUsername(@Param("username") String username); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /p9-springboot-transaction/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #开发环境 2 | app: 3 | env: dev 4 | -------------------------------------------------------------------------------- /p9-springboot-transaction/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #生产环境 2 | app: 3 | env: prod -------------------------------------------------------------------------------- /p9-springboot-transaction/src/main/resources/config/config.properties: -------------------------------------------------------------------------------- 1 | boy.name=xiaoming 2 | boy.age=34 -------------------------------------------------------------------------------- /p9-springboot-transaction/src/test/java/com/yanger/SpringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.yanger; 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 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | --------------------------------------------------------------------------------