我正在使用Hibernate和Spring作为我的Web应用程序.
在数据库操作中,Hibernate正在缓存实体并在下一个请求中返回它们而不读取实际的数据库.我知道这将减少数据库的负担并提高性能.
但是,虽然这个应用程序仍在构建中,但我需要在每个请求中加载数据库中的数据(测试原因).
有没有办法强制数据库读取?
我从这个log4j消息中确定了缓存.
Returning cached instance of singleton bean 'HelloController'
DEBUG [http-bio-8080-exec-42] - Last-Modified value for [/myApp/../somePageId.html] is: -1
Run Code Online (Sandbox Code Playgroud) 我使用的是Spring Boot(1.5.6),Hibernate,Postgres,Hikari(2.7.8).我的配置是:
spring.datasource.hikari.minimumIdle=1
spring.datasource.hikari.maximumPoolSize=20
spring.datasource.hikari.idleTimeout=30000
spring.datasource.hikari.poolName=SpringBootJPAHikariCP
spring.datasource.hikari.maxLifetime=50000
spring.datasource.hikari.connectionTimeout=30000
Run Code Online (Sandbox Code Playgroud)
我期望的是,空闲连接应在30000ms/30秒空闲后释放.
问题在于每个请求都要建立新的连接,保留所有空闲连接.所以经过一段时间我最终得到了20个空闲连接并且有了新的请求Hikari试图获得一个新的连接并得到SpringBootJPAHikariCP - Connection is not available, request timed out after 30001ms.
那么,我做错了什么.或者误解了配置?
Hikari初始化日志:
SpringBootJPAHikariCP - configuration:
allowPoolSuspension.............false
autoCommit......................true
catalog.........................none
connectionInitSql...............none
connectionTestQuery.............none
connectionTimeout...............30000
dataSource......................none
dataSourceClassName.............none
dataSourceJNDI..................none
dataSourceProperties............{password=<masked>}
driverClassName................."org.postgresql.Driver"
healthCheckProperties...........{}
healthCheckRegistry.............none
idleTimeout.....................30000
initializationFailFast..........true
initializationFailTimeout.......1
isolateInternalQueries..........false
jdbc4ConnectionTest.............false
jdbcUrl.........................jdbc:postgresql://localhost:5432/dbname
leakDetectionThreshold..........0
maxLifetime.....................50000
maximumPoolSize.................20
metricRegistry..................none
metricsTrackerFactory...........none
minimumIdle.....................1
password........................<masked>
poolName........................"SpringBootJPAHikariCP"
readOnly........................false
registerMbeans..................false
scheduledExecutor...............none
scheduledExecutorService........internal
schema..........................none
threadFactory...................internal
transactionIsolation............default
username........................"postgres"
validationTimeout...............5000
Run Code Online (Sandbox Code Playgroud)
更新: 在过去24小时内,我尝试了来自不同线程的多个解决方案,但没有一个解决了我的问题.所以这里的观察可能很重要.
SpringBootJPAHikariCP - Reset (autoCommit) on connection org.postgresql.jdbc.PgConnection@1344bbf1找到了这个日志.研究了
在HikariCP这个线程中连接时的重置(autoCommit).试图auto commit …只验证单词最简单的正则表达式(我认为)
/^\w+$/
Run Code Online (Sandbox Code Playgroud)
我想排除数字并_从中排除(因为它aa10aa现在接受和aa_aa,我想拒绝它们)
我认为它可以通过
/^[a-zA-z]+$/
Run Code Online (Sandbox Code Playgroud)
这意味着我必须采取不同于前一种方法的方法.
但如果我想排除在此范围内的任何字符想我不会允许k,K,p,P或者更多.
有没有办法在范围内添加排除列表而不更改范围.?
Magento全文搜索无法正常工作
我做了以下步骤
全文搜索选项启用 system->configuration->catalogsearch
和
app/code/core/Mage/CatalogSearch/Model/resources/Fulltext.php
Run Code Online (Sandbox Code Playgroud)
更改
$likeCond = '(' . join(' OR ', $like) . ')';
Run Code Online (Sandbox Code Playgroud)
至
$likeCond = '(' . join(' AND', $like) . ')';
Run Code Online (Sandbox Code Playgroud)
但我仍然无法搜索fulltext完全匹配的单词.
我必须读取一个本地或远程文件.
文件路径或URI将来自用户输入.
目前我只读本地文件
public String readFile(String fileName)
{
File file=new File(fileName);
BufferedReader bufferedReader = null;
try {
bufferedReader = new BufferedReader(new FileReader(file));
StringBuilder stringBuilder = new StringBuilder();
String line;
while ( (line=bufferedReader.readLine())!=null ) {
stringBuilder.append(line);
stringBuilder.append(System.lineSeparator());
}
return stringBuilder.toString();
} catch (FileNotFoundException e) {
System.err.println("File : \""+file.getAbsolutePath()+"\" Not found");
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
finally {
try {
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
参数String fileName是用户输入,可以是本地文件的路径,或者URI …
我正在使用Luna,现在正考虑升级到火星.
我在默认情况下在Luna中找不到导入中的CVS选项.
他们在火星上把它移走了吗?
我有以下键值系统(HashMap),其中String将是像这样的"2014/12/06"的键.
LinkedHashMap<String, Value>
Run Code Online (Sandbox Code Playgroud)
所以,我可以检索一个知道密钥的项目,但我正在寻找的是一种方法来检索一个值的列表,哪个密钥匹配部分匹配,我的意思是,我怎样才能检索到2014年的所有值?
我想避免像测试列表中的每个项目,暴力或类似的解决方案.
谢谢.
当我试图学习一些框架J2EE时,我正在研究spring框架.
在一些教程中让我困惑的事情是他们将Spring MVC作为spring框架的一部分.但在某些地方,他们提到的就像一个不同的独立框架.有些人甚至比较Spring MVC和Struts(这是我理解的另一个框架).
现在我应该如何将Spring MVC作为一个不同的框架,如Struts或作为Spring的一部分?
我想创建SSL连接.我创建了密钥库.并尝试使用x509.
final KeyManagerFactory kmf = KeyManagerFactory.getInstance("X509");
Run Code Online (Sandbox Code Playgroud)
但是我跑完后在控制台上遇到异常.
java.security.NoSuchAlgorithmException:X509 KeyManagerFactory在javax.net.ssl.KeyManagerFactory.getInstance(未知来源)的sun.security.jca.GetInstance.getInstance(未知来源)中不可用SSLContext sc = SSLContext.getInstance(connectionType); final char [] keyPassPhrase ="changeit".toCharArray(); // String [] array = Security.getProviders(); final KeyStore ks = KeyStore.getInstance("jks");
ks.load(new FileInputStream("ClientKeyStore"), keyPassPhrase);
provider();
final KeyManagerFactory kmf = KeyManagerFactory.getInstance("X509"); // this line is problem
// SunX509 : supporting only: [TLSv1, TLSv1.1, TLSv1.2]
kmf.init(ks, keyPassPhrase);
sc.init(kmf.getKeyManagers(), new TrustManager[] {
new X509TrustManager(){
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkClientTrusted(X509Certificate[] arg0, String arg1)
throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] arg0, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用jquery-ui draggable一些元素可拖动.我将helper选项设置clone 为当前元素.
它正在使克隆正确,但当我放弃克隆消失.它不会停留在被拖曳的地方.
请参阅演示小提琴链接
$('#drag').draggable({
helper: function (e, ui) {
return $(this).clone();
}
});
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
javascript jquery jquery-ui jquery-ui-draggable jquery-draggable
java ×5
spring ×3
hibernate ×2
javascript ×2
caching ×1
cryptography ×1
eclipse ×1
eclipse-mars ×1
frameworks ×1
hashmap ×1
hikaricp ×1
io ×1
java-io ×1
jquery ×1
jquery-ui ×1
key-value ×1
magento ×1
php ×1
regex ×1
spring-boot ×1
spring-mvc ×1
ssl ×1