2017-04-24 66 views
0

我開發了一個Spring Rest應用程序。我沒有添加任何特定連接池的代碼。我正在考慮HikariCP,骨骼CP或CP30。Spring MVC/Rest是否有其自己的默認連接池?

有人告訴我Spring MVC/Rest有自己的內部連接池,所以即使我沒有實現我自己的任何一個,也不會有任何問題。

我試圖在互聯網上找到,但有一些疑問。請澄清。

回答

0

不,Spring沒有默認的連接池,它使用Web服務器[Tomcat]線程請求處理,並大量使用Threadlocal,但對於數據庫操作,您可以使用它們中的任何一個作爲您的願望,添加其他配置會覆蓋其他配置。 Tomcat的春天開機:

server.tomcat.accept-count= # Maximum queue length for incoming connection requests when all possible request processing threads are in use. 
    server.tomcat.accesslog.buffered=true # Buffer output such that it is only flushed periodically. 
    server.tomcat.accesslog.directory=logs # Directory in which log files are created. Can be relative to the tomcat base dir or absolute. 
    server.tomcat.accesslog.enabled=false # Enable access log. 
    server.tomcat.accesslog.file-date-format=.yyyy-MM-dd # Date format to place in log file name. 
    server.tomcat.accesslog.pattern=common # Format pattern for access logs. 
    server.tomcat.accesslog.prefix=access_log # Log file name prefix. 
    server.tomcat.accesslog.rename-on-rotate=false # Defer inclusion of the date stamp in the file name until rotate time. 
    server.tomcat.accesslog.request-attributes-enabled=false # Set request attributes for IP address, Hostname, protocol and port used for the request. 
    server.tomcat.accesslog.rotate=true # Enable access log rotation. 
    server.tomcat.accesslog.suffix=.log # Log file name suffix. 
    server.tomcat.additional-tld-skip-patterns= # Comma-separated list of additional patterns that match jars to ignore for TLD scanning. 
    server.tomcat.background-processor-delay=30 # Delay in seconds between the invocation of backgroundProcess methods. 
    server.tomcat.basedir= # Tomcat base directory. If not specified a temporary directory will be used. 
    server.tomcat.internal-proxies=10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\ 
      192\\.168\\.\\d{1,3}\\.\\d{1,3}|\\ 
      169\\.254\\.\\d{1,3}\\.\\d{1,3}|\\ 
      127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\ 
      172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\ 
      172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\ 
      172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # regular expression matching trusted IP addresses. 
    server.tomcat.max-connections= # Maximum number of connections that the server will accept and process at any given time. 
    server.tomcat.max-http-post-size=0 # Maximum size in bytes of the HTTP post content. 
    server.tomcat.max-threads=0 # Maximum amount of worker threads. 
    server.tomcat.min-spare-threads=0 # Minimum amount of worker threads. 
    server.tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value. 
    server.tomcat.protocol-header= # Header that holds the incoming protocol, usually named "X-Forwarded-Proto". 
    server.tomcat.protocol-header-https-value=https # Value of the protocol header that indicates that the incoming request uses SSL. 
    server.tomcat.redirect-context-root= # Whether requests to the context root should be redirected by appending a/to the path. 

對數據來源​​:

# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) 
spring.datasource.continue-on-error=false # Do not stop if an error occurs while initializing the database. 
spring.datasource.data= # Data (DML) script resource references. 
spring.datasource.data-username= # User of the database to execute DML scripts (if different). 
spring.datasource.data-password= # Password of the database to execute DML scripts (if different). 
spring.datasource.dbcp2.*= # Commons DBCP2 specific settings 
spring.datasource.driver-class-name= # Fully qualified name of the JDBC driver. Auto-detected based on the URL by default. 
spring.datasource.generate-unique-name=false # Generate a random datasource name. 
spring.datasource.hikari.*= # Hikari specific settings 
spring.datasource.initialize=true # Populate the database using 'data.sql'. 
spring.datasource.jmx-enabled=false # Enable JMX support (if provided by the underlying pool). 
spring.datasource.jndi-name= # JNDI location of the datasource. Class, url, username & password are ignored when set. 
spring.datasource.name=testdb # Name of the datasource. 
spring.datasource.password= # Login password of the database. 
spring.datasource.platform=all # Platform to use in the schema resource (schema-${platform}.sql). 
spring.datasource.schema= # Schema (DDL) script resource references. 
spring.datasource.schema-username= # User of the database to execute DDL scripts (if different). 
spring.datasource.schema-password= # Password of the database to execute DDL scripts (if different). 
spring.datasource.separator=; # Statement separator in SQL initialization scripts. 
spring.datasource.sql-script-encoding= # SQL scripts encoding. 
spring.datasource.tomcat.*= # Tomcat datasource specific settings 
spring.datasource.type= # Fully qualified name of the connection pool implementation to use. By default, it is auto-detected from the classpath. 
spring.datasource.url= # JDBC url of the database. 
spring.datasource.username= # Login user of the database. 
spring.datasource.xa.data-source-class-name= # XA datasource fully qualified name. 
spring.datasource.xa.properties= # Properties to pass to the XA data source.