# springboot-example **Repository Path**: yangkailan/springboot-example ## Basic Information - **Project Name**: springboot-example - **Description**: No description available - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-06-25 - **Last Updated**: 2020-12-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README + 开发环境为jdk1.8+idea+maven + spring boot 例子,所有东西都是使用最简化配置,避免杂乱 - [x] SpringBoot-config 配置文件及默认配置 - [x] SpringBoot-jpa 整合jpa及使用默认的hikari连接池 - [x] SpringBoot-jpa-tomcatdatasource 整合jpa及使用tomcat连接池 - [x] SpringBoot-jpa-druiddatasource 整合jpa及使用druid连接池 - [x] SpringBoot-jpa-page-sort 整合jpa及分页和排序 - [x] SpringBoot-jpa-multi_datasource 整合jpa及使用多个数据源 - [x] SpringBoot-thymeleaf 整合thymeleaf - [x] SpringBoot-Redis 整合redis - [x] SpringBoot-mybatis 整合mybatis(xml版本) - [x] Sring-test springboot单元测试 - [x] SpringBoot-mybatis-annotation 整合mybatis(注解版本) - [x] SpringBoot-mybatis-multi-datasource 整合mybatis,使用多个数据源 - [x] SpringBoot-mybatis-redis-annotation 整合mybatis和redis(注解版本) - [x] SpringBoot-ExceptionHandler 异常处理 - [ ] WebFlux - [ ] WebFlux-restful - [ ] WebFlux-Thymeleaf - [ ] WebFlux-MongoDB - [ ] WebFlux-MongoDB-Thymeleaf - [ ] WebFlux-redis - [ ] WebFlux-websocket - [ ] SpringBoot-Spring-Shell - [ ] SpringBoot-Elasticsearch - [ ] SpringBoot-elasticsearch-query - [ ] SpringBoot-dubbo-client - [ ] SpringBoot-dubbo-server - [ ] SpringBoot-freemarker - [ ] [spring-hateoas](https://spring.io/guides/gs/rest-hateoas/) - [ ] [term.js 实现webshell](https://blog.csdn.net/yelllowcong/article/details/79039608) - [ ] [不要被名字吓到-RESTful、HATEOAS、Spring boot之整合](https://www.jianshu.com/p/65b9e54dee7d) - [ ] [史上最简单的 SpringCloud 教程](https://blog.csdn.net/forezp/article/details/70148833) - [ ] [Spring 官网](https://spring.io/projects/) - [ ] java 版宝塔 [[layers]] name = "lang#java" [[layers]] name = "git" [[layers]] name = "lang#go" [[layers]] name = "lang#html" [[layers]] name = "lang#markdown" [[layers]] name = "lang#plantuml" [[layers]] name = "lang#python" [[layers]] name = "ui" + http://docs.studygolang.com/doc/install + source /etc/profile + yum install neovim + curl -sLf https://spacevim.org/install.sh | bash -s -- --install neovim + vim ~/.SpaceVim.d/init.toml ``` #============================================================================= # basic.toml --- basic configuration example for SpaceVim # Copyright (c) 2016-2017 Wang Shidong & Contributors # Author: Wang Shidong < wsdjeg at 163.com > # URL: https://spacevim.org # License: GPLv3 #============================================================================= # All SpaceVim option below [option] section [options] # set spacevim theme. by default colorscheme layer is not loaded, # if you want to use more colorscheme, please load the colorscheme # layer colorscheme = "gruvbox" colorscheme_bg = "dark" # Disable guicolors in basic mode, many terminal do not support 24bit # true colors enable_guicolors = false # Disable statusline separator, if you want to use other value, please # install nerd fonts statusline_separator = "nil" statusline_inactive_separator = "bar" buffer_index_type = 4 windows_index_type = 3 enable_tabline_filetype_icon = false enable_statusline_mode = false statusline_unicode_symbols = false # Enable vim compatible mode, avoid changing origin vim key bindings vimcompatible = true # Enable autocomplete layer [[layers]] name = 'autocomplete' auto-completion-return-key-behavior = "complete" auto-completion-tab-key-behavior = "cycle" [[layers]] name = 'shell' default_position = 'top' default_height = 30 [[layers]] name = "lang#java" [[layers]] name = "git" [[layers]] name = "lang#go" [[layers]] name = "lang#html" [[layers]] name = "lang#markdown" [[layers]] name = "lang#plantuml" [[layers]] name = "lang#python" [[layers]] name = "ui" ``` + yum install "java-11-openjdk.x86_64" + wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz + wget -N --no-check-certificate https://bootstrap.pypa.io/get-pip.py && chmod +x get-pip.py && python get-pip.py + wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz + pip3 install neovim + pip3 show neovim + failed to load python3 host,:checkhealth,ln -s /usr/local/bin/python3 /usr/bin/python3 解决 [deoplete] deoplete failed to load. Try the :UpdateRemotePlugins command and restart Neovim. See also :checkhealth. + xz -d your_file_name.tar.xz + tar -xvf your_file_name.tar + :SPUpdate + markdown : npm -g install remark npm -g install remark-cli npm -g install remark-stringify + go [deoplete] gocode binary no found go get -u github.com/nsf/gocode go install github.com/nsf/gocode gocode set propose-builtins true + python + java 默认的openjdk 没有javac 命令--yum install java-devel public class Main(){ public static void main(String args[]){ System.out.println("abc"); } } + cloud9 [root@VM_49_174_centos c9sdk]# node server.js --port 80 --listen 0.0.0.0 Starting standalone Authentication is required when not running on localhost. If you would like to expose this service to other hosts or the Internet at large, please specify -a user:pass to set a username and password (or use -a : to force no login). Use --listen localhost to only listen on the localhost interface and and suppress this message. Warning: running Cloud9 without using HTTP authentication. Run using --listen localhost instead to only expose Cloud9 to localhost, or use -a username:password to setup HTTP authentication Connect server listening at http://127.0.0.1:80 CDN: version standalone initialized /root/c9sdk/build Started '/root/c9sdk/configs/standalone' with config 'standalone'! Cloud9 is up and running ^C [root@VM_49_174_centos c9sdk]# node server.js --port 80 --listen 0.0.0.0 -a : Starting standalone Warning: running Cloud9 without using HTTP authentication. Run using --listen localhost instead to only expose Cloud9 to localhost, or use -a username:password to setup HTTP authentication Connect server listening at http://10.105.49.174:80 CDN: version standalone initialized /root/c9sdk/build Started '/root/c9sdk/configs/standalone' with config 'standalone'! Cloud9 is up and running node server.js --port 80 --listen 0.0.0.0 -w ./ -a : + hexo+ocean: gitalk: https://github.com/settings/applications/new hexo admin https://www.jianshu.com/p/68e727dda16d + ssl 证书+httpd https://www.jianshu.com/p/c6a34ba70fba,记得iptables放行443端口 + apache 反向代理https://blog.csdn.net/i_iphone/article/details/53747266 参数 描述 --prefix= Directory for NGINX files, and the base location for all relative paths set by the other configure script options (excluding paths to libraries) and for the path to the nginx.conf configuration file. Default: /usr/local/nginx. --sbin-path= Name of the NGINX executable file, which is used only during installation. Default: /sbin/nginx --conf-path= Name of the NGINX configuration file. You can, however, always override this value at startup by specifying a different file with the -c option on the nginx command line. Default: conf/nginx.conf --pid-path= Name of the nginx.pid file, which stores the process ID of the nginx master process. After installation, the path to the filename can be changed with the pid directive in the NGINX configuration file. Default: /logs/nginx.pid --error-log-path= Name of the primary log file for errors, warnings, and diagnostic data. After installation, the filename can be changed with the the error_log directive in the NGINX configuration file. Default: /logs/error.log --http-log-path= Name of the primary log file for requests to the HTTP server. After installation, the filename can always be changed with the access_log directive in the NGINX configuration file. Default: /logs/access.log --user= Name of the unprivileged user whose credentials are used by the NGINX worker processes. After installation, the name can be changed with the user directive in the NGINX configuration file. Default: nobody --group= Name of the group whose credentials are used by the NGINX worker processes. After installation, the name can be changed with the user directive in the NGINX configuration file. Default: the value set by the --user option. --with-pcre= Path to the source for the PCRE library, which is required for regular expressions support in the location directive and the Rewrite module. --with-pcre-jit Builds the PCRE library with “just-in-time compilation” support (the pcre_jit directive). --with-zlib= Path to the source for the zlib library, which is required by the Gzip module. --with-cpp_test_module Tests the C++ compatibility of header files. --with-debug Enables the debugging log. --with-file-aio Enables asynchronous I/O. ``–``with-google_perftools_module Allows using Google Performance tools library. -- with-http_addition_module Adds text before and after a response. -- with-http_auth_request_module Implements client authorization based on the result of a subrequest. -- with-http_dav_module Enables file management automation using the WebDAV protocol. --with-http_degradation_module Allows returning an error when a memory size exceeds the defined value. -- with-http_flv_module Provides pseudo-streaming server-side support for Flash Video (FLV) files. -- with-http_geoip_module Enables creating variables whose values depend on the client IP address. The module uses MaxMind GeoIP databases. To compile as a separate dynamic module instead, change the option to –with-http_geoip_module=dynamic. -- with-http_gunzip_module Decompresses responses with Content-Encoding: gzip for clients that do not support the _zip_ encoding method. -- with-http_gzip_static_module Allows sending precompressed files with the .gz filename extension instead of regular files. -- with-http_image_filter_module Transforms images in JPEG, GIF, and PNG formats. The module requires the LibGD library. To compile as a separate dynamic module instead, change the option to --with-http_image_filter_module=dynamic. -- with-http_mp4_module Provides pseudo-streaming server-side support for MP4 files. -- with-http_perl_module Used to implement location and variable handlers in Perl and insert Perl calls into SSI. Requires the PERL library. To compile as a separate dynamic module instead, change the option to --with-http_perl_module=dynamic. -- with-http_random_index_module Processes requests ending with the slash character (‘/’) and picks a random file in a directory to serve as an index file. -- with-http_realip_module Changes the client address to the one sent in the specified header field. -- with-http_secure_link_module Used to check authenticity of requested links, protect resources from unauthorized access, and limit link lifetime. -- with-http_slice_module Allows splitting a request into subrequests, each subrequest returns a certain range of response. Provides more effective caching of large files. -- with-http_ssl_module Enables HTTPS support. Requires an SSL library such as OpenSSL. -- with-http_stub_status_module Provides access to basic status information. Note that NGINX Plus customers do not require this module as they are already provided with extended status metrics and interactive dashboard. -- with-http_sub_module Modifies a response by replacing one specified string by another. -- with-http_xslt_module Transforms XML responses using one or more XSLT stylesheets. The module requires the Libxml2 and XSLT libraries. To compile as a separate dynamic module instead, change the option to --with-http_xslt_module=dynamic. -- with-http_v2_module Enable support for HTTP/2. See The HTTP/2 Module in NGINX on the NGINX blog for details. -- with-mail Enables mail proxy functionality. To compile as a separate dynamic module instead, change the option to --with-mail=dynamic. -- with-mail_ssl_module Provides support for a mail proxy server to work with the SSL/TLS protocol. Requires an SSL library such as OpenSSL. -- with-stream Enables the TCP and UDP proxy functionality. To compile as a separate dynamic module instead, change the option to --with-stream=dynamic. -- with-stream_ssl_module Provides support for a stream proxy server to work with the SSL/TLS protocol. Requires an SSL library such as OpenSSL. --with-threads Enables NGINX to use thread pools. For details, see Thread Pools in NGINX Boost Performance 9x! on the NGINX blog. 要配置HTTPS服务器,ssl必须 在服务器块中的侦听套接字上启用该参数 ,并且 应指定服务器证书 和 私钥文件的位置 : 服务器{ 听443 ssl ; server_name www.example.com; ssl_certificate www.example.com.crt ; ssl_certificate_key www.example.com.key ; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; ... } 服务器证书是公共实体。它被发送到连接到服务器的每个客户端。私钥是一个安全的实体,应该存储在具有受限访问权限的文件中,但是,它必须是nginx的主进程可读的。私钥可以替代地存储在与证书相同的文件中: ssl_certificate www.example.com.cert; ssl_certificate_key www.example.com.cert; 在这种情况下,还应限制文件访问权限。虽然证书和密钥存储在一个文件中,但只有证书才会发送到客户端。 指令ssl_protocols和 ssl_ciphers 可用于限制连接以仅包括SSL / TLS的强版本和密码。默认情况下,nginx使用“ ssl_protocols TLSv1 TLSv1.1 TLSv1.2”和“ ssl_ciphers HIGH:!aNULL:!MD5”,因此通常不需要显式配置它们。请注意,这些指令的默认值已 多次更改。 HTTPS服务器优化 SSL操作会消耗额外的CPU资源。在多处理器系统上, 应运行多个 工作进程,不少于可用CPU核心数。CPU占用最多的操作是SSL握手。有两种方法可以最大限度地减少每个客户端的这些操作数量:第一种方法是通过启用 keepalive 连接来通过一个连接发送多个请求,第二种方法是重用SSL会话参数以避免SSL并行连接和后续连接。会话存储在worker之间共享的SSL会话高速缓存中,并由ssl_session_cache 指令配置 。一兆字节的缓存包含大约4000个会话。默认缓存超时为5分钟。它可以通过使用增加 ssl_session_timeout 指令。以下是针对具有10兆字节共享会话缓存的多核系统优化的示例配置: worker_processes auto ; http { ssl_session_cache共享:SSL:10m ; ssl_session_timeout 10m ; 服务器{ 听443 ssl; server_name www.example.com; keepalive_timeout 70 ; ssl_certificate www.example.com.crt; ssl_certificate_key www.example.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; ... SSL证书链 某些浏览器可能会抱怨由知名证书颁发机构签名的证书,而其他浏览器可能会毫无问题地接受证书。发生这种情况是因为颁发机构使用中间证书对服务器证书进行了签名,该中间证书不存在于与特定浏览器一起分发的众所周知的可信证书颁发机构的证书库中。在这种情况下,授权机构提供一组链式证书,这些证书应连接到签名的服务器证书。服务器证书必须出现在组合文件中的链式证书之前: $ cat www.example.com.crt bundle.crt> www.example.com.chained.crt 生成的文件应该在 ssl_certificate指令中使用: 服务器{ 听443 ssl; server_name www.example.com; ssl_certificate www.example.com.chained.crt; ssl_certificate_key www.example.com.key; ... } 如果服务器证书和软件包的连接顺序错误,则nginx将无法启动并显示错误消息: SSL_CTX_use_PrivateKey_file(“... /www.example.com.key”)失败 (SSL:错误:0B080074:x509证书例程: X509_check_private_key:键值不匹配) 因为nginx尝试将私钥与bundle的第一个证书而不是服务器证书一起使用。 浏览器通常存储他们收到的中间证书,并由受信任的权威机构签名,因此主动使用的浏览器可能已经拥有所需的中间证书,并且可能不会抱怨没有链接束发送的证书。要确保服务器发送完整的证书链,openssl可以使用命令行实用程序,例如: $ openssl s_client -connect www.godaddy.com:443 ... 证书链 0 s:/C=US/ST=Arizona/L=Scottsdale/1.3.6.1.4.1.311.60.2.1.3=US /1.3.6.1.4.1.311.60.2.1.2=AZ/O=GoDaddy.com,Inc / OU = MIS部门/ CN = www.GoDaddy.com /serialNumber=0796928-7/2.5.4.15=V1.0,第5条。(b) 我:/ C = US / ST = Arizona / L = Scottsdale / O = GoDaddy.com,Inc。 /OU=http://certificates.godaddy.com/repository / CN = Go Daddy Secure Certification Authority / SERIALNUMBER = 07969287 1 s:/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com,Inc。 /OU=http://certificates.godaddy.com/repository / CN = Go Daddy Secure Certification Authority / SERIALNUMBER = 07969287 i:/ C = US / O = Go Daddy Group,Inc。 / OU =去Daddy Class 2认证机构 2 s:/ C = US / O = Go Daddy Group,Inc。 / OU =去Daddy Class 2认证机构 i:/ L = ValiCert验证网络/ O = ValiCert,Inc。 / OU = ValiCert Class 2 Policy Validation Authority /CN=http://www.valicert.com//emailAddress=info@valicert.com ... 使用SNI测试配置时,指定-servername选项非常重要,因为openssl默认情况下不使用SNI。 在该示例中,服务器证书#0 的主题(“ s ”) www.GoDaddy.com由发行者(“ i ”)签名,发行者本身是证书#1的主题,其由发行者签署,发行者本身是发行者的主题。证书#2,由知名发行人ValiCert,Inc。签署, 其证书存储在浏览器的内置证书库(位于Jack建造的房屋内)中。 如果尚未添加证书包,则仅显示服务器证书#0。 单个HTTP / HTTPS服务器 可以配置处理HTTP和HTTPS请求的单个服务器: 服务器{ 听80; 听443 ssl; server_name www.example.com; ssl_certificate www.example.com.crt; ssl_certificate_key www.example.com.key; ... } 在0.7.14之前,无法为个别侦听套接字选择性地启用SSL,如上所示。只能使用ssl指令为整个服务器启用 SSL,从而无法设置单个HTTP / HTTPS服务器。添加ssl了listen指令的参数 来解决此问题。因此不鼓励在现代版本中使用 ssl指令。 基于名称的HTTPS服务器 配置侦听单个IP地址的两个或多个HTTPS服务器时会出现一个常见问题: 服务器{ 听443 ssl; server_name www.example.com; ssl_certificate www.example.com.crt; ... } 服务器{ 听443 ssl; server_name www.example.org; ssl_certificate www.example.org.crt; ... } 使用此配置,浏览器将接收默认服务器的证书,即www.example.com无论请求的服务器名称如何。这是由SSL协议行为引起的。在浏览器发送HTTP请求之前建立SSL连接,并且nginx不知道所请求服务器的名称。因此,它可能只提供默认服务器的证书。 解决此问题的最古老,最强大的方法是为每个HTTPS服务器分配一个单独的IP地址: 服务器{ 听192.168.1.1:443 ssl; server_name www.example.com; ssl_certificate www.example.com.crt; ... } 服务器{ 听192.168.1.2:443 ssl; server_name www.example.org; ssl_certificate www.example.org.crt; ... } 具有多个名称的SSL证书 还有其他方法允许在多个HTTPS服务器之间共享单个IP地址。但是,所有这些都有它们的缺点。一种方法是在SubjectAltName证书字段中使用具有多个名称的证书,例如, www.example.com和www.example.org。但是,SubjectAltName字段长度是有限的。 另一种方法是使用带有通配符名称的证书,例如 *.example.org。通配符证书可保护指定域的所有子域,但仅限于一个级别。此证书匹配www.example.org,但不匹配 example.org和www.sub.example.org。这两种方法也可以组合使用。证书可以包含在SubjectAltName字段准确和通配符的名称,例如, example.org和*.example.org。 最好将具有多个名称的证书文件及其私钥文件放在配置的http级别,以在所有服务器中继承其单个内存副本: ssl_certificate common.crt; ssl_certificate_key common.key; 服务器{ 听443 ssl; server_name www.example.com; ... } 服务器{ 听443 ssl; server_name www.example.org; ... } 服务器名称指示 在单个IP地址上运行多个HTTPS服务器的更通用的解决方案是 TLS服务器名称指示扩展(SNI,RFC 6066),它允许浏览器在SSL握手期间传递请求的服务器名称,因此,服务器将知道哪个它应该用于连接的证书。目前 大多数现代浏览器都支持 SNI ,但某些老客户或特殊客户可能无法使用。 只有域名可以在SNI中传递,但是如果请求包含文字IP地址,某些浏览器可能会错误地将服务器的IP地址作为其名称传递。人们不应该依赖于此。 为了在nginx中使用SNI,必须在构建nginx二进制文件的OpenSSL库以及在运行时动态链接到的库中支持它。如果使用配置选项“--enable-tlsext”构建,OpenSSL支持0.9.8f版本的SNI 。 自OpenSSL 0.9.8j以来,默认情况下启用此选项。如果nginx是使用SNI支持构建的,那么当使用“-V”开关运行时,nginx将显示: $ nginx -V ... 启用了TLS SNI支持 ... 但是,如果启用SNI的nginx动态链接到没有SNI支持的OpenSSL库,nginx会显示警告: nginx是在SNI支持下构建的,但现在已经链接了 动态到没有tlsext支持的OpenSSL库, 因此SNI不可用 兼容性 自0.8.21和0.7.62以来,“-V”开关显示SNI支持状态。 自0.7.14起支持listen指令 的ssl参数 。在0.8.21之前,它只能与参数一起指定 。 default SNI自0.5.23以来一直受到支持。 自0.5.6以来一直支持共享SSL会话缓存。 版本1.9.1及更高版本:默认的SSL协议是TLSv1,TLSv1.1和TLSv1.2(如果受OpenSSL库支持)。 版本0.7.65,0.8.19及更高版本:默认的SSL协议是SSLv3,TLSv1,TLSv1.1和TLSv1.2(如果OpenSSL库支持)。 版本0.7.64,0.8.18及更早版本:默认的SSL协议是SSLv2,SSLv3和TLSv1。 版本1.0.5及更高版本:默认的SSL密码为“ HIGH:!aNULL:!MD5”。 版本0.7.65,0.8.20及更高版本:默认SSL密码为“ HIGH:!ADH:!MD5”。 版本0.8.19:默认的SSL密码为“ ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM”。 版本0.7.64,0.8.18及更早版本:默认SSL密码为 “ ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP”。 来自客户端的TCP / UDP会话在称为阶段的连续步骤中处理: Post-accept 接受客户端连接后的第一阶段。该ngx_stream_realip_module 模块在这个阶段被调用。 Pre-access 初步检查访问。该ngx_stream_limit_conn_module 模块在这个阶段被调用。 Access 实际数据处理前的客户端访问限制。该ngx_stream_access_module 模块在这个阶段被调用。 SSL TLS / SSL终止。该ngx_stream_ssl_module 模块在这个阶段被调用。 Preread 将初始数据字节读入 预读缓冲区, 以允许诸如ngx_stream_ssl_preread_module之类的模块 在处理之前分析数据。 Content 实际处理数据的强制阶段(通常 代理到 上游服务器)或指定值返回给客户端。 Log 记录客户端会话处理结果的最后阶段。该ngx_stream_log_module 模块在这个阶段被调用。