我只是尝试了IntelliJ,因为Eclipse再次让我恼火.我进口了我的gradle项目(jetty,vaadin),它进展顺利.但是当我尝试运行它时,我在"make"期间遇到以下错误消息:
错误:gradle-resources-test:vaadinsharedwidgets:java.lang.NoClassDefFoundError:org/apache/tools/ant/util/ReaderInputStream
"vaadinsharedwidgets"是该项目的一个模块.根据我从错误中理解,IntelliJ没有找到蚂蚁,但这是因为我不使用蚂蚁.它也不是传递依赖的一部分.同样的项目在eclipse中运行良好,并且在gradle工程中构建它没有任何问题.
更新:我刚刚在Eclipse中检查过,不知何故ant.jar在Eclipse的类路径中,但是我无法将它链接到任何项目.我想知道它是如何实现的.
Update2:缺少版本信息:
build.gradle
:
apply from: 'http://nexus/gradle/vaadin.gradle'
apply from: 'http://nexus/gradle/java8.gradle'
version = '1.1'
description = "Gemeinsame Vaadin-Widgets"
vaadin.widgetset 'net.xyz.vaadinsharedwidgets.VaadinsharedWidgetsWidgetset'
dependencies {
compile project(':ibhtheme')
compile 'com.vaadin:vaadin-server:' + vaadin.version
compile 'com.vaadin:vaadin-client:' + vaadin.version
}
jar{
// Include source in jar
from sourceSets.main.allJava
}
sourceSets.main.resources.srcDir 'src/main/webapp'
Run Code Online (Sandbox Code Playgroud)
vaadin.gradle:
apply from: 'http://plugins.jasoft.fi/vaadin.plugin?version=0.9.2'
configurations {
def conf = 'vaadin-client'
def sources = project.sourceSets.main
def testSources = project.sourceSets.test …
Run Code Online (Sandbox Code Playgroud) 今天我尝试将集成测试从maven切换到gradle.一切都很好,除了我有一个严重的问题与testng.
该项目使用hibernate/JPA2进行数据库访问,并且有一些依赖于test/resources/META-INF/persistence.xml中的持久性单元的测试.当我使用gradle运行测试套件时,一切正常.但是当我从eclipse运行xml(或任何测试类)时,它似乎尝试使用main/resources/META-INF/persistence.xml.
因为我使用TDD完成了大部分工作,所以我真的需要从eclipse运行/调试测试.当我将持久性单元添加到生产persistence.xml时,它可以工作(它甚至可以从"test"目录中获取一些其他资源).这将是一种解决方法,但我真的不喜欢将测试资源添加到"主要/资源"的想法
当我使用maven中的旧pom.xml导入它时,同一项目工作正常.
的build.gradle
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.7
version = '0.1'
jar {
manifest {
attributes 'Implementation-Title': 'md', 'Implementation-Version': version
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.5'
compile 'com.google.guava:guava:14.0.1'
compile 'org.hibernate:hibernate-entitymanager:4.2.2.Final'
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final'
testCompile 'ch.qos.logback:logback-classic:1.0.13'
testCompile 'org.testng:testng:6.8.5'
testCompile 'org.dbunit:dbunit:2.4.9'
testCompile 'org.mockito:mockito-all:1.9.5'
testCompile 'org.easytesting:fest-assert-core:2.0M10'
testCompile 'org.hsqldb:hsqldb:2.2.9'
}
test {
useTestNG(){
suites 'src/test/resources/testng.xml'
}
}
Run Code Online (Sandbox Code Playgroud)
更新:
生成的类路径文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="src" path="src/test/resources"/> …
Run Code Online (Sandbox Code Playgroud) 我目前正在调试一个使用spring boot(1.1.2.Release)构建的小应用程序.如果连接丢失(由于生产中的wait_timeout或开发中的连接被杀),我遇到了重新连接到数据库的问题.我目前正在使用以下配置参数(application.properties):
spring.datasource.url=jdbc:mysql://localhost:3306/test?autoreconnect=true
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.test-on-borrow=true
spring.datasource.test-while-idle=true
spring.datasource.validation-query=SELECT 1;
spring.datasource.initial-size=2
... username+pw
spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
Run Code Online (Sandbox Code Playgroud)
这导致以下数据源:
org.apache.tomcat.jdbc.pool.DataSource@73e369e5{ConnectionPool[
defaultAutoCommit=null;
defaultReadOnly=null;
defaultTransactionIsolation=-1;
defaultCatalog=null;
driverClassName=com.mysql.jdbc.Driver;
maxActive=100;
maxIdle=100;
minIdle=10;
initialSize=2;
maxWait=30000;
testOnBorrow=true;
testOnReturn=false;
timeBetweenEvictionRunsMillis=5000;
numTestsPerEvictionRun=0;
minEvictableIdleTimeMillis=60000;
testWhileIdle=true;
testOnConnect=false;
password=********;
url=jdbc:mysql://localhost:3306/test?autoreconnect=true;
username=test;
validationQuery=SELECT 1;
;
validationQueryTimeout=-1;
validatorClassName=null;
validationInterval=30000;
accessToUnderlyingConnectionAllowed=true;
removeAbandoned=false;
removeAbandonedTimeout=60;
logAbandoned=false;
connectionProperties=null;
initSQL=null;
jdbcInterceptors=null;
jmxEnabled=true;
fairQueue=true;
useEquals=true;
abandonWhenPercentageFull=0;
maxAge=0;
useLock=false;
dataSource=null;
dataSourceJNDI=null;
suspectTimeout=0;
alternateUsernameAllowed=false;
commitOnReturn=false;
rollbackOnReturn=false;
useDisposableConnectionFacade=true;
logValidationErrors=false;
propagateInterruptState=false;
ignoreExceptionOnPreLoad=false;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,当连接丢失时,需要很长时间才能重新建立连接.同时,用户获得一个空页面,并在服务器端抛出异常.根据我的理解,testOnBorrow应该在每次使用前测试连接,每30秒测试一次testWhileIdle.但事实并非如此.当我看到mysql时,似乎每隔35秒发生一次事情并且睡眠时间重置,但我在应用程序日志中看不到任何查询.验证查询似乎完全缺失.
我通过spring数据库访问数据库.
我目前没有进一步的想法尝试.
我不知道如何使用hashmap和while循环从我的数据库中检索数据.请帮助我.
我的代码是
package com.glomindz.mercuri.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import com.glomindz.mercuri.util.MySingleTon;
public class UserServicesDAO {
private Connection connection;
public UserServicesDAO() {
//connection = new MySingleTon().getConnection();
connection = MySingleTon.getInstance().getConnection();
}
public void get_all_data() {
HashMap<Integer, String> result = new HashMap<Integer, String>();
String query = "SELECT * FROM spl_user_master";
try {
PreparedStatement stmt = connection.prepareStatement(query);
boolean execute = stmt.execute();
System.out.println(execute);
ResultSet resultSet = stmt.getResultSet();
System.out.println(resultSet.getMetaData());
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} …
Run Code Online (Sandbox Code Playgroud) java ×3
gradle ×2
eclipse ×1
jdbc ×1
mysql ×1
spring ×1
spring-boot ×1
spring-data ×1
testng ×1