Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Search | Email

部分 I. Spring Framework

目录

4. Spring Tool Suite
4.1. 安装
4.2. Dashboard
5. Spring Boot
5.1. Spring Boot Quick start
5.1.1. pom.xml
5.1.2. Controller
5.2. 运行 Spring boot 项目
5.2.1. Maven run
5.2.2. Linux systemd
5.2.3. 传统 init.d 脚本
5.3. application.properties
5.3.1. PID FILE
5.3.2. 内嵌 tomcat server
5.3.2.1. server.tomcat.basedir
5.3.2.2. server
5.3.2.3. tomcat
5.3.2.4. logging
5.3.2.5. charset
5.3.2.6. Session 配置
5.3.2.7. cookie
5.3.2.8. error 路径
5.3.2.9. 压缩传输
5.3.2.10. server.servlet.context-path
5.3.2.11. ssl
5.3.3. JSON
5.3.4. SMTP 相关配置
5.3.5. Redis
5.3.6. MongoDB
5.3.7. MySQL
5.3.8. Oracle
5.3.9. default_schema
5.3.10. datasource
5.3.11. velocity
5.3.12.
5.4. SpringApplication
5.4.1. @SpringBootApplication
5.4.2. @EnableAutoConfiguration
5.4.3. @ComponentScan
5.4.4. CharacterEncodingFilter
5.4.5. 隐藏 Banner
5.4.6. CORS 跨域请求
5.4.7. 实体与仓库扫描
5.4.8. 列出 Beans
5.5. 编译用于Tomcat的 War
5.6. Properties
5.6.1. @EnableConfigurationProperties 引用自定义 *.properties 配置文件
5.6.2. spring.profiles.active 参数切换配置文件
5.6.3. SpringApplicationBuilder.properties() 方法添加配置项
5.7. Service
5.7.1. Application
5.7.2. 定义接口
5.7.3. 实现接口
5.7.4. 调用 Service
5.8. ViewResolver
5.8.1. Maven
5.8.2. application.properties
5.8.3. Application
5.8.4. IndexController
5.8.5. src/main/webapp/WEB-INF/jsp/index.jsp
5.8.6. 集成模板引擎
5.9. String boot with RestTemplate
5.9.1. 在控制器中完整实例
5.10. Spring boot with Logging
5.10.1. 打印日志
5.10.2. 日志输出级别
5.10.3. 禁止控制台输出日志
5.10.4. 标准输出
5.10.5. 日志分割
5.10.6. 日志写入 MongoDB
5.11. Spring boot with Session share
5.11.1. Redis
5.11.1.1. Maven
5.11.1.2. application.properties
5.11.1.3. Application
5.11.2. 测试 Session
5.11.3. JDBC
5.12. Connection and Statement Pooling
5.12.1. org.apache.tomcat.jdbc.pool.DataSource
5.12.2. druid
5.12.3. c3p0 - JDBC3 Connection and Statement Pooling
5.12.4. dbcp2
5.12.5. bonecp
5.12.6. dbcp2
5.13. Spring boot with MongoDB
5.13.1. Maven
5.13.2. Application
5.13.3. MongoTemplate
5.13.4. Repository
5.14. Spring boot with MySQL
5.14.1. Maven
5.14.2. Resource
5.14.3. Application
5.14.4. JdbcTemplate
5.14.5. CrudRepository
5.15. Spring boot with Oracle
5.15.1. Maven
5.15.2. application.properties
5.15.3. Application
5.15.4. CrudRepository
5.15.5. JdbcTemplate
5.15.6. Controller
5.16. Spring boot with PostgreSQL
5.16.1. pom.xml
5.16.2. application.properties
5.16.3. Application
5.16.4. CrudRepository
5.16.5. JdbcTemplate
5.16.6. Controller
5.16.7. Test
5.17. Spring boot with Email
5.17.1. Maven
5.17.2. Resource
5.17.3. POJO
5.17.4. RestController
5.17.5. Test
5.18. Spring boot with Velocity template
5.18.1. Maven
5.18.2. Resource
5.18.3. Application
5.18.4. RestController
5.18.5. Test
5.19. Spring boot with Spring security
5.19.1. Maven
5.19.2. Reource
5.19.3. Application
5.19.4. WebSecurityConfigurer
5.19.5. RestController
5.19.6. 测试
5.19.7. Spring + Security + MongoDB
5.19.7.1. Account
5.19.7.2. AccountRepository
5.19.7.3. WebSecurityConfiguration
5.20. Spring boot with Oauth2
5.20.1. Maven
5.20.2. Password tools
5.20.3. Server
5.20.3.1. Maven
5.20.3.2. application.properties
5.20.3.3. EnableAuthorizationServer
5.20.3.4. EnableResourceServer
5.20.3.5. Entity Table
5.20.3.6. UserRepository
5.20.3.7. UserService
5.20.3.8. TestRestController
5.20.3.9. 数据库初始化
5.20.3.10. Test
5.20.4. Client
5.20.4.1. Maven
5.20.4.2. SpringBootApplication
5.20.4.3. ClientRestController
5.20.4.4. Test
5.21. Spring boot with Scheduling
5.21.1. Application.java
5.21.2. Component
5.21.3. 查看日志
5.21.4. 计划任务控制
5.22. Spring boot with Cache
5.22.1. Spring boot with Redis
5.22.1.1. maven
5.22.1.2. application.properties
5.22.1.3. JUnit
5.22.1.4. Controller
5.22.2. @Cacheable
5.22.2.1. maven
5.22.2.2. Controller
5.23. Spring boot with Hessian
5.23.1. Maven
5.23.2. Application
5.23.3. HessianServiceExporter
5.23.4. Service
5.23.5. RestController
5.24. Spring boot with Apache Kafka
5.24.1. 安装 kafka
5.24.2. maven
5.24.3. Spring boot Application
5.24.4. EnableKafka
5.24.5. KafkaListener
5.24.6. 测试
5.24.7. 完整的发布订阅实例
5.25. Spring boot with Git version
5.25.1. CommonRestController 公共控制器
5.25.2. VersionRestController 测试控制器
5.25.3. 创建 .gitattributes 文件
5.26. Spring boot with HTTPS SSL
5.26.1. 生成自签名证书
5.26.2. application.properties 配置文件
5.26.3. 启动 Spring boot
5.26.4. restTemplate 调用实例
5.27. Spring boot with Elasticsearch 2.x
5.27.1. Maven
5.27.2. Application
5.27.3. application.properties
5.27.4. Domain
5.27.5. ElasticsearchRepository
5.28. Spring boot with Elasticsearch 5.5.x
5.28.1. Maven
5.28.2. Application
5.28.3. application.properties
5.28.4. ElasticsearchConfiguration
5.28.5. RestController
5.29. Spring boot with Apache Hive
5.29.1. Maven
5.29.2. application.properties
5.29.3. Configuration
5.29.4. CURD 操作实例
5.30. Spring boot with Phoenix
5.30.1. Maven
5.30.2. application.properties
5.30.3. Configuration
5.31. Spring boot with Data restful
5.31.1. Maven
5.32. Spring boot with ELK(Elasticsearch + Logstash + Kibana)
5.32.1. TCP 方案
5.32.2. Redis 方案
5.32.3. Kafka 方案
5.32.4. Other
5.33. Spring boot with Docker
5.33.1.
5.33.2.
5.33.3.
5.33.4.
5.34. SpringBootTest
5.34.1.
5.35. FAQ
5.35.1. application.properties 参考
5.35.2. org.hibernate.dialect.Oracle10gDialect does not support identity key generation
5.35.3. No identifier specified for entity
5.35.4. Could not read document: Invalid UTF-8 middle byte 0xd0
5.35.5. java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
5.35.6. Field javaMailSender in cn.netkiller.rest.EmailRestController required a bean of type 'org.springframework.mail.javamail.JavaMailSender' that could not be found.
5.35.7. org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "172.16.0.3", user "test", database "test ", SSL off
5.35.8. Spring boot 怎样显示执行的SQL语句
6. Spring MVC
6.1. @Controller
6.1.1. @RequestMapping
6.1.1.1. @RequestMapping("/")
6.1.1.2. 映射多个URL
6.1.1.3. headers
6.1.2. RequestMapping with Path Variables - @PathVariable
6.1.2.1. URL 参数传递
6.1.2.2. URL 传递 Date 类型
6.1.2.3. 处理特殊字符
6.1.2.4. @PathVariable 注意事项
6.1.3. RequestMapping with Request Parameters - @RequestParam
6.1.3.1. HTTP GET
6.1.3.2. HTTP POST
6.1.3.3. @RequestParam 传递特殊字符串
6.1.3.4. 传递日期参数
6.1.4. @RequestBody
6.1.5. @ModelAttribute
6.1.6. @CookieValue
6.1.7. @RequestHeader
6.1.8. @@SessionAttributes
6.1.9.
6.1.10. @ResponseBody
6.1.10.1. 直接返回HTML
6.1.11. ModelAndView
6.1.11.1. 变量传递
6.1.11.2. ModelMap 传递多个变量
6.1.11.3. redirect
6.1.11.4. ArrayList
6.1.11.5. HashMap
6.1.11.6. 传递对象
6.1.11.7.
6.1.12. @Scheduled
6.1.13. @CrossOrigin
6.1.14. @SessionAttributes
6.1.15. HttpServletRequest / HttpServletResponse
6.1.15.1. 用于方法参数
6.1.15.2. 注入方式
6.2. @RestController
6.2.1. 返回实体
6.2.2. JSON
6.2.3. XML
6.2.4. 兼容传统 json 接口
6.2.5. @PageableDefault 分页
6.3. View
6.3.1. Using Spring’s form tag library
6.3.1.1. css
6.3.1.1.1. cssClass
6.3.1.1.2. cssStyle
6.3.1.1.3. cssErrorClass
6.3.1.2. cssClass
6.3.2. Thymeleaf
6.3.2.1. Maven pom.xml
6.3.2.2. Spring 配置
6.3.2.3. controller
6.3.2.4. HTML5 Template
6.3.3. FreeMarker
6.4. Properties
6.4.1. 载入*.properties文件
6.4.2. @Value 注解
6.4.3. @PropertySource 注解
6.5. FAQ
6.5.1. o.s.web.servlet.PageNotFound
6.5.2. HTTP Status 500 - Handler processing failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
6.5.3. 同时使用 Thymeleaf 与 JSP
6.5.4. 排除静态内容
6.5.5. HTTP Status 406
7. RestTemplate - Spring4 Restful
7.1. RestTemplate Example
7.1.1. pom.xml
7.1.2. web.xml
7.1.3. springframework.xml
7.1.4. RestController
7.1.5. POJO
7.1.6. 测试
7.2. getForObject
7.2.1. 返回字符串
7.2.2. 传递 GET 参数
7.3. postForObject
7.3.1. 传递对象
7.3.2. 传递数据结构 MultiValueMap
7.4. postForEntity
7.5. PUT
7.6. Delete
7.7. HTTP Auth
7.7.1. Client
8. Spring Data Redis
8.1. pom.xml
8.2. springframework-servlet.xml
8.3. Controller
8.4. index.jsp
8.5. 测试
9. Spring Data MongoDB
9.1. Example Spring Data MongoDB
9.1.1. pom.xml
9.1.2. springframework-servlet.xml
9.1.3. POJO
9.1.4. Controller
9.1.5. 查看测试结果
9.1.6. 条件查询
9.2. @Document
9.2.1. @Indexed
9.2.1.1. 普通索引
9.2.1.2. 唯一索引
9.2.2. @DateTimeFormat
9.2.3. @NumberFormat
9.2.4. 在 @Document 中使用 Enum 类型
9.2.5. 在 @Document 中定义数据结构 List/Map
9.3. MongoRepository
9.3.1. findAll()
9.3.2. deleteAll()
9.3.3. save()
9.3.4. count()
9.3.5. findByXXXX
9.3.6. StartingWith 和 EndingWith
9.3.7. Between
9.3.8. PageRequest
9.3.9. @Query
9.4. mongoTemplate
9.4.1. is
9.4.2. Regex 正则表达式搜索
9.4.3. lt 和 gt
9.4.4. between
9.4.5. Criteria
9.4.6. Sort
9.4.7. Query + PageRequest
9.4.8. newAggregation
10. Spring Data JPA
10.1. @Entity
10.1.1. @Id
10.1.2. @Table
10.1.3. @Column
10.1.3.1. 字段长度
10.1.3.2. 浮点型
10.1.3.3. 创建于更新控制
10.1.4. @NotNull 不能为空声明
10.1.5. @DateTimeFormat 处理日期时间格式
10.1.6. 默认时间规则
10.1.6.1. CreatedDate
10.1.6.2. 与时间日期有关的 hibernate 注解
10.1.6.2.1. 设置默认时间
10.1.6.2.2. 创建时间
10.1.6.2.3. 更新时间
10.1.6.3. 数据库级别的默认创建日期时间定义
10.1.6.4. 数据库级别的默认创建日期与更新时间定义
10.1.6.5. 最后修改时间
10.1.7. 索引
10.1.8. Enum 枚举数据类型
10.1.8.1. 实体中处理 enum 类型
10.1.8.2. 数据库枚举类型
10.1.9. 整形数据类型
10.1.10. @JoinColumn
10.1.11. @OneToOne
10.1.12. OneToMany 一对多
10.1.13. ManyToMany 多对多
10.1.14. 外键级联删除
10.1.15. 其他
10.1.15.1. Cascade
10.1.15.2. @JsonIgnore
10.2. 实体集成
10.3. Repository
10.3.1. 传递枚举参数
10.3.2. 翻页操作
10.3.3. 排序操作操作
10.3.4. OrderBy
10.3.5. Query
10.3.5.1. 参数传递
10.3.6. @Transactional
10.3.6.1. 删除更新需要 @Transactional 注解
10.3.6.2. 回滚操作
10.4. CrudRepository
10.5. JpaRepository
10.6. JdbcTemplate
10.6.1. execute
10.6.2. queryForInt
10.6.3. queryForObject
10.6.3.1. 返回整形与字符型
10.6.3.2. 查询 Double 类型数据库
10.6.3.3. 返回日期
10.6.3.4. 返回结果集
10.6.3.5. 通过 "?" 向SQL传递参数
10.6.4. queryForList
10.7. EntityManager
10.8. Spring Data FAQ
10.8.1. No identifier specified for entity
10.8.2. Oracle Date 类型显示日期和时间
10.8.3. Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException: Executing an update/delete query
11. Elasticsearch
11.1. 内嵌 Elasticsearch
11.1.1. Maven
11.1.2. src/main/resources/application.properties
11.1.3. Domain Class
11.1.4. ElasticsearchRepository
11.1.5. SearchRestController
11.1.6. 测试
11.2. 集群模式
11.3. Document
11.4. Elasticsearch 删除操作
11.5. FAQ
11.5.1. java.lang.IllegalStateException: Received message from unsupported version: [2.0.0] minimal compatible version is: [5.0.0]
12. Spring Security
12.1. EnableWebSecurity
12.1.1. 访问控制列表(Access Control List,ACL)
12.1.2. WebSecurity
12.1.3. HTTP Auth
12.1.4. Rest
12.1.5. hasRole
12.1.6. Add User
12.2. 获取当前用户
12.3. HTTP 安全
13. Interceptor
13.1. WebMvcConfigurerAdapter
13.2. HandlerInterceptor
14. Spring Cloud
14.1. Spring Cloud Config
14.1.1. Git 仓库
14.1.2. Server
14.1.2.1. Maven
14.1.2.2. Application
14.1.2.3. application.properties
14.1.2.4. 测试服务器
14.1.2.5. Maven pom.xml (Camden.SR5)
14.1.3. Client
14.1.3.1. Maven pom.xml
14.1.3.2. Application
14.1.3.3. bootstrap.properties
14.1.3.4. 测试 client
14.1.3.5. Maven pom.xml (Camden.SR5)
14.1.4. Config server 用户认证
14.1.4.1. Server 配置
14.1.4.1.1. application.properties
14.1.4.1.2. Maven
14.1.4.1.3. 测试是否生效
14.1.4.2. Client 配置
14.1.5. 加密敏感数据
14.2. Spring Cloud Netflix
14.2.1. Eureka Server
14.2.1.1. Maven
14.2.1.2. Application
14.2.1.3. application.properties
14.2.1.4. 检查注册服务器
14.2.1.5. 为 Eureka Server 增加用户认证
14.2.1.5.1. Maven
14.2.1.5.2. application.properties
14.2.1.5.3. Eureka Client
14.2.1.5.4. Feign Client
14.2.2. Eureka Client
14.2.2.1. Maven
14.2.2.2. Application
14.2.2.3. RestController
14.2.2.4. application.properties
14.2.2.5. 测试
14.2.3. Feign client
14.2.3.1. Maven
14.2.3.2. Application
14.2.3.3. interface
14.2.3.4. application.properties
14.2.3.5. 测试
14.2.3.6. fallback
14.2.4. Zuul
14.2.4.1. Maven
14.2.4.2. EnableZuulProxy
14.2.4.3. application.yml
14.2.4.4. 负载均衡配置
14.3. FAQ
14.3.1. Feign请求超时
14.3.2. Eureka Client (Dalston.SR1)
14.3.2.1. Maven
14.3.2.2. Application
14.3.2.3. RestController
14.3.2.4. application.properties
14.3.2.5. 测试
14.3.3. Feign 启动出错 PathVariable annotation was empty on param 0.
15. Tomcat Spring 运行环境
15.1. Maven
15.2. Spring Boot Quick start
15.2.1. pom.xml
15.2.2. Controller
15.3. Spring MVC configuration
15.4. Tomcat
15.5. 集成 Mybatis
15.5.1. pom.xml
15.5.2. properties
15.5.3. dataSource
15.5.4. SqlSessionFactory
15.5.5. Mapper 扫描
15.5.6. Mapper 单一class映射
15.5.7. Service
15.5.8. 测试实例