小编opi*_*ike的帖子

在单个修订版中使用工作副本的Subversion问题

我正在使用subclipse将来自主干的更改合并到一个分支中,并且在"最佳实践"步骤中,通知工作副本不在单个修订版中.软件包资源管理器中的文件或文件夹都没有脏指示符(之前已通过此操作),即使在进行更新后,也没有任何版本号显示已更改.具体是什么subclipse看生成这个通知?有什么我也可以从命令行运行来证实这一点吗?

eclipse subclipse svn

4
推荐指数
1
解决办法
6369
查看次数

Cakephp:如何将值传递到javascript文件中?

我有一些javascript被包含在视图中,我在这个帖子中使用了inkedmn的方法:add -page-specific-javascript-to-each-view-in-cakephp

所以我现在在我的视图中有以下代码:

$this->set('jsIncludes',array('google'));   // this will link to /js/google.js
Run Code Online (Sandbox Code Playgroud)

但是我需要将一些值从视图传递到javascript文件中,我不确定如何实现这一点.

更新:我想一个选项是回显php文件中的值,包含在div标签中,然后在javascript代码中使用getElementById().

javascript php cakephp

3
推荐指数
1
解决办法
6529
查看次数

使用http://www.hibernate.org/dtd的Hibernate问题

我目前在我的hibernate配置文件中使用http://hibernate.sourceforge.net作为我的命名空间,这给了我这些警告:

公认的过时的hibernate名称空间 http://hibernate.sourceforge.net/.请改用名称空间 http://www.hibernate.org/dtd/.请参阅Hibernate 3.6迁移指南!

所以我尝试将hibernate.cfg.xml和所有其他*.hbm.xml文件切换到使用http://www.hibernate.org/dtd.然而,当我尝试使用eclipse中的hibernate工具生成代码时,我收到以下错误消息(代码生成与其他命名空间一起工作正常):

org.hibernate.HibernateException:无法解析配置:C:\ dev\workspace\DataLoad\hibernate.cfg.xml无法解析配置:C:\ dev\workspace\DataLoad\hibernate.cfg.xml
org.dom4j.DocumentException: www.hibernate.org嵌套异常:www.hibernate.org www.hibernate.org嵌套异常:www.hibernate.org org.dom4j.DocumentException:www.hibernate.org嵌套异常:www.hibernate.org www.hibernate.org嵌套异常:www.hibernate.org

这是我的hibernate.cfg.xml:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>
        <!-- Database connection settings -->
        <property name="connection.driver_class">
            com.mysql.jdbc.Driver
        </property>
        <property name="connection.url">
            jdbc:mysql://localhost:3306/findata?tcpKeepAlive=true
        </property>
        <property name="connection.username">root</property>
        <property name="connection.password">xxxxxxxx</property>

        <property name="connection.pool_size">2</property>
        <property name="show_sql">true</property>
        <property name="dialect">
            org.hibernate.dialect.MySQLDialect
        </property>
        <property name="current_session_context_class">thread</property>
        <property name="cache.provider_class">
            org.hibernate.cache.NoCacheProvider
        </property>

        <mapping resource="conf/Alert.hbm.xml" />
        <mapping resource="conf/Entity.hbm.xml" />
        <mapping resource="conf/FactData.hbm.xml" />
        <mapping resource="conf/TimeEvent.hbm.xml" />
        <mapping resource="conf/User.hbm.xml" /> …
Run Code Online (Sandbox Code Playgroud)

java eclipse hibernate

3
推荐指数
1
解决办法
2万
查看次数

Java终于阻止了问题

是否有一种内置方法可以在finally块中确定您是否刚刚从catch块中出来?我知道这可以通过下面的变量轻松完成,但我很好奇是否有标准的内置方式.

boolean bException = false;
try
{
    dbf = new DBFunctions();
    dbf.db_run_query(query2);
    dbf.rs.next();
    nMonth = dbf.rs.getInt("calquarter") * 3;
    nYear = dbf.rs.getInt("calyear");

}
catch (SQLException sqle)
{
    out.println(sqle.toString());
    bException = true;
}
finally
{
    dbf.closeConnection();
    if (bException == true)
        return;
}
Run Code Online (Sandbox Code Playgroud)

更新:以下是closeConnection()方法的内容,它只是试图关闭所有数据库对象:

public void closeConnection()
{

    if (rs != null)
    {
        try { rs.close(); } catch (SQLException e) { ; }
        rs = null;
    }

    if (stmt != null)
    {
        try { stmt.close(); } catch (SQLException e) { ; }
        stmt …
Run Code Online (Sandbox Code Playgroud)

java exception-handling try-catch-finally

2
推荐指数
1
解决办法
590
查看次数

Java:BufferedInputStream的available()方法问题

我正在处理以下用于将大文件拆分为一组较小文件的代码:

FileInputStream input = new FileInputStream(this.fileToSplit);
            BufferedInputStream iBuff = new BufferedInputStream(input);
            int i = 0;

            FileOutputStream output = new FileOutputStream(fileArr[i]);
            BufferedOutputStream oBuff = new BufferedOutputStream(output);

            int buffSize = 8192;
            byte[] buffer = new byte[buffSize];
            while (true) {
                if (iBuff.available() < buffSize) {
                    byte[] newBuff = new byte[iBuff.available()];
                    iBuff.read(newBuff);
                    oBuff.write(newBuff);
                    oBuff.flush();
                    oBuff.close();

                    break;
                }
                int r = iBuff.read(buffer);

                if (fileArr[i].length() >= this.partSize) {
                    oBuff.flush();
                    oBuff.close();
                    ++i;
                    output = new FileOutputStream(fileArr[i]);
                    oBuff = new BufferedOutputStream(output);
                }
                oBuff.write(buffer);
            }

        } catch (Exception e) …
Run Code Online (Sandbox Code Playgroud)

java file-io

2
推荐指数
1
解决办法
3881
查看次数

Java:jsplitpane和boxlayout的问题

我想摆脱jsplitpanes左边的空白区域:

截图

这是我的代码:

getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane.add(downloadsPanel);
splitPane.add(filesPanel);

JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane2.add(processingPanel);
splitPane2.add(messagePanel);

JSplitPane splitPane3 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

splitPane3.add(splitPane);
splitPane3.add(splitPane2);

getContentPane().add(addPanel);
getContentPane().add(splitPane3);
Run Code Online (Sandbox Code Playgroud)

java swing jsplitpane boxlayout

2
推荐指数
1
解决办法
975
查看次数

java.io.FileNotFoundException:无法打开类路径资源[timex-servlet.properties],因为它不存在

我尝试启动Spring Web应用程序时收到以下错误消息:

2012-04-12 13:53:20,491 ERROR [org.springframework.web.servlet.DispatcherServlet] - 

Context initialization failed
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [timex-servlet.properties] cannot be opened because it does not exist
java.io.FileNotFoundException: class path resource [timex-servlet.properties] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:137)
    at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:172)
Run Code Online (Sandbox Code Playgroud)

我正在通过eclipse运行Tomcat(版本6.x).我尝试将timex-servlet.properties放在以下目录中,但无济于事:

WebContent\WEB-INF
WebContent\WEB-INF\classes
WebContent\
Run Code Online (Sandbox Code Playgroud)

以下是timex-servlet.xml中timex-servlet.properties的引用:

    <bean id="placeholderConfig"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location"
        value="timex-servlet.properties" />
</bean>
Run Code Online (Sandbox Code Playgroud)

有几个SO线程处理相同的消息,表示放置类路径:在属性文件引用前面.所以我尝试了以下,但也没有用:

        <bean id="placeholderConfig"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location"
        value="classpath:timex-servlet.properties" />
</bean>
Run Code Online (Sandbox Code Playgroud)

spring filenotfoundexception properties-file timex

2
推荐指数
1
解决办法
5万
查看次数

使用Junit和spring

我正试图用spring建立一个junit,我正在尝试使用spring的依赖注入来填充测试类.我想知道这是否是我应该尝试的东西?我认为我看到的是spring正在实例化测试类并执行DI但是JUnit正在创建它自己的实例,该实例没有执行DI并且测试失败.我正在使用JUnit 4.x和spring 3.1.1.

java junit spring

2
推荐指数
1
解决办法
697
查看次数

覆盖 javascript 函数,同时保留原始上下文

我只是想确认我没有遗漏有关管理上下文和重写方法的内容。我在 node.js 应用程序中使用 http-proxy 模块,并且需要重写函数 HttpProxy.prototype.proxyRequest。我想在不直接修改原始模块代码的情况下做到这一点,但一直无法找到一种方法来做到这一点。

如果我这样做:

var httpProxy = require('http-proxy'),
httpProxyOverride = require('./http-proxy-override.js');

httpProxy.HttpProxy.prototype.proxyRequest = httpProxyOverride.proxyRequestOverride;
Run Code Online (Sandbox Code Playgroud)

然后我失去了原始的上下文并抛出错误。如果我使用 apply(),我可以提供一个新的上下文,但我似乎无法保留原始上下文。

基于此 SO 线程: 是否可以在不更改上下文的情况下调用 function.apply? 似乎没有办法实现我想要做的事情,我希望有人可以证实这一点,或者如果我错了,可以纠正我。

javascript closures

2
推荐指数
1
解决办法
2179
查看次数

selenium:等待元素可点击不起作用

我正在尝试使用 Expected_conditions.element_to_be_clickable 但它似乎不起作用。在大约 30% 的运行中,我仍然看到“元素...不可点击”错误。

这是完整的错误消息:

selenium.common.exceptions.WebDriverException:消息:未知错误:元素...在点(621、337)处不可单击。其他元素将收到点击:...(会话信息:chrome=60.0.3112.90)(驱动程序信息:chromedriver=2.26.436421(6c1a3ab469ad86fd49c8d97ede4a6b96a49ca5f6),platform=Mac OS X 10.12.6 x86_64)

这是我正在使用的代码:

def wait_for_element_to_be_clickable(selector, timeout=10):
  global driver
  wd_wait = WebDriverWait(driver, timeout)

  wd_wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, selector)),
    'waiting for element to be clickable ' + selector)
  print ('WAITING')
  return driver.find_element_by_css_selector(selector)
Run Code Online (Sandbox Code Playgroud)

更新:

所以现在这真的很奇怪。即使我添加几个固定的等待时间,它仍然偶尔会抛出错误消息。这是进行调用的代码:

  sleep(5)
  elem = utils.wait_for_element_to_be_clickable('button.ant-btn-primary')
  sleep(5)
  elem.click()
Run Code Online (Sandbox Code Playgroud)

python selenium selenium-webdriver

2
推荐指数
1
解决办法
8585
查看次数

删除 Jenkins 中的构建历史记录

我正在尝试使用此答案中的说明从 Jenkins 删除构建历史记录:

如何清除我的 Jenkins/Hudson 构建历史记录?

但是,我收到以下错误消息:

groovy.lang.MissingMethodException:没有方法签名:jenkins.branch.OrganizationFolder.getBuilds() 适用于参数类型:() 值:[] 可能的解决方案:getViews()、doBuild(jenkins.util.TimeDuration)、getUrl( ), getClass(), getActions(), getApi() 在 org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58) 在 org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java :49)在org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)在org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)在org.codehaus。 groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)

如果我运行这个脚本:

def jobName = "github-test"
def job = Jenkins.instance.getItem(jobName)
println(job)
Run Code Online (Sandbox Code Playgroud)

我得到以下输出:

jenkins.branch.OrganizationFolder@134f3a3c[github-test]

我使用的是2.32.2版本。

这是我运行的确切脚本:

def jobName = "github-test"
def job = Jenkins.instance.getItem(jobName)
job.getBuilds().each { it.delete() }
job.nextBuildNumber = 1
job.save()
Run Code Online (Sandbox Code Playgroud)

groovy jenkins

1
推荐指数
1
解决办法
5685
查看次数