小编Cug*_*uga的帖子

构建日期 - 一种有效的方式

我是否知道使用特定日期,月份和年份构建日期对象的最有效方法是什么.

Date(int year, int month, int day) 
Run Code Online (Sandbox Code Playgroud)

此结构已折旧.因此,我通常做的是:

Calendar calendar = Calendar.getInstance();
Date date = calendar.set(year, month, date).getTime();
Run Code Online (Sandbox Code Playgroud)

但是,我的理解是Calendar.getInstance()相当昂贵.构造Date对象的最有效方法是什么?或者我应该静静地使用Date(int year,int month,int day)而不告诉其余的?

请不要建议使用任何第三方库.

java

15
推荐指数
2
解决办法
9913
查看次数

为什么maven找不到osgi bundle依赖?

我在我的maven项目中声明了一个OSGi包作为依赖项.(它恰好是felix容器.)

<dependency>
    <groupId>org.apache.felix</groupId>
    <artifactId>org.apache.felix.framework</artifactId>
    <version>4.0.2</version>
    <type>bundle</type>
    <scope>compile</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

当我尝试构建时,它说它无法找到它.

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) org.apache.felix:org.apache.felix.framework:bundle:4.0.2

  Try downloading the file manually from the project website.
Run Code Online (Sandbox Code Playgroud)

但是,快速查看中心会验证此工件确实存在.我注意到,如果我将其更改为"jar"类型,它确实会为我下载jar(包).这让我思考,为什么我首先称它为捆绑?好吧,我这样做是因为当我使用m2e查找工件时,它称之为"捆绑"; 事实上,m2e生成了我在上面引用的那些坐标.

bundle不是有效的maven工件类型吗?如果没有,为什么m2e称之为?

osgi bundle m2eclipse maven

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

wsimport - 两个声明导致冲突,给出相同的行

尝试wsimport用于为SOAP端点生成客户端.WSDL和使用的所有XSD文件都是本地副本.

这是正在执行的命令:

wsimport ./bwWsdl.xml -p com.generated -Xnocompile -d ../src -extension -keep -XadditionalHeaders -B-XautoNameResolution
Run Code Online (Sandbox Code Playgroud)

这给出了这个错误:

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 16 of file:/schemas/newSchema.xsd

[ERROR] (Related to above error) This is the other declaration.   
  line 16 of file:/schemas/newSchema.xsd
Run Code Online (Sandbox Code Playgroud)

请注意,报告的碰撞的行号是相同的.

这是架构:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
  version="2.004" id="OTA2003A2009A">

  <xs:complexType name="TPA_ExtensionsType">
    <xs:annotation>
      <xs:documentation xml:lang="en">Description here.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:element name="TPA_Extensions" type="TPA_ExtensionsType">
    <xs:annotation>
      <xs:documentation xml:lang="en">More description here.</xs:documentation>
    </xs:annotation>
  </xs:element> …
Run Code Online (Sandbox Code Playgroud)

java xsd jaxb wsimport

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

如何在Spring中管理对象池?

据我所知,在Spring中,默认情况下所有对象都被视为单例.如果将singleton设置为false,则将在每个请求中提供新对象.

但是如果我想要聚集对象呢?设置范围从最小1到最多10个实例?这有可能使用Spring吗?

java aop spring spring-mvc object-pooling

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

如何使用nosetests输出覆盖率XML?

我正在尝试输出我的鼻子测试的覆盖率XML,以便他们出现在Hudson上.我正在执行的行是:

nosetests --with-gae -v --all-modules --with-xunit --with-coverage
Run Code Online (Sandbox Code Playgroud)

我在控制台中看到了coverage输出,但是没有包含coverage数据的xml文件.如何让它输出coverage xml?

python code-coverage cobertura nosetests

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

如何在Spring Batch中设置多线程?

我已经成功建立了一个Spring Batch项目教程.我真的很想知道是否可以在"Spring级别"使其成为多线程.

我想要的基本思路是制作一个任务列表或任务步骤,让它们被独立的线程拾取和处理,理想情况下是一个限于'n'个线程的池.

这可能吗?如果是这样,怎么样?有人可以从我目前所在的地方指导我到那一点吗?

简单的项目我是从本教程在这里.它基本上有不同的任务,可以将信息打印到屏幕上.

这是我当前的simpleJob.xml文件,其中包含作业详细信息:

<import resource="applicationContext.xml"/>

    <bean id="hello" class="helloworld.PrintTasklet">
        <property name="message" value="Hello"/>
    </bean>

    <bean id="space" class="helloworld.PrintTasklet">
        <property name="message" value=" "/>
    </bean>

    <bean id="world" class="helloworld.PrintTasklet">
        <property name="message" value="World!\n"/>
    </bean>

    <bean id="taskletStep" class="org.springframework.batch.core.step.tasklet.TaskletStep" >
        <property name="jobRepository" ref="jobRepository"/>
        <property name="transactionManager" ref="transactionManager"/>
    </bean>

    <bean id="simpleJob" class="org.springframework.batch.core.job.SimpleJob">
        <property name="name" value="simpleJob" />
        <property name="steps">
            <list>
                <bean parent="taskletStep">
                    <property name="tasklet" ref="hello"/>
                </bean>
                <bean parent="taskletStep">
                    <property name="tasklet" ref="space"/>
                </bean>
                <bean parent="taskletStep">
                    <property name="tasklet" ref="world"/>
                </bean>
            </list>
        </property>
        <property name="jobRepository" ref="jobRepository"/>
    </bean>
Run Code Online (Sandbox Code Playgroud)

我的appContext包含作业存储库bean(SimpleJobRepository),事务管理器( …

java spring multithreading spring-batch

13
推荐指数
2
解决办法
4万
查看次数

如何在Google App引擎数据模型类型中覆盖equals()?

我正在使用Google App Engine的Python库.如何覆盖equals()类上的方法,以便它判断user_id以下类字段的相等性:

class UserAccount(db.Model):
    # compare all equality tests on user_id
    user = db.UserProperty(required=True)
    user_id = db.StringProperty(required=True)
    first_name = db.StringProperty()
    last_name = db.StringProperty()
    notifications = db.ListProperty(db.Key)
Run Code Online (Sandbox Code Playgroud)

现在,我通过获得一个UserAccount对象并做着做同样的事情user1.user_id == user2.user_id.有没有办法可以覆盖它,以便'user1 == user2'只查看'user_id'字段?

提前致谢

python google-app-engine web-applications

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

如何将JTable单元格输入标记为无效?

如果我采用a JTable并在其模型上指定列的classtype,如下所示:

   DefaultTableModel model = new DefaultTableModel(columnNames, 100) {
       @Override
        public Class<?> getColumnClass(int columnIndex) {
            return Integer.class;
        }};
Run Code Online (Sandbox Code Playgroud)

然后,只要用户尝试double在表中输入值,Swing就会自动拒绝输入并将单元格的轮廓设置为红色.

当某人输入单元格的"负数或0"输入时,我希望发生相同的效果.我有这个:

    @Override
    public void setValueAt(Object val, int rowIndex, int columnIndex) {
       if (val instanceof Number && ((Number) val).doubleValue() > 0) {
              super.setValueAt(val, rowIndex, columnIndex);
            } 
       }
   }
Run Code Online (Sandbox Code Playgroud)

这可以防止单元格接受任何非正值,但不会将颜色设置为红色并使单元格保持可编辑状态.

我试着调查JTable默认情况下是如何做出拒绝的,但我似乎无法找到它.

如何拒绝非正输入与拒绝非整数输入相同?

谢谢

java validation swing jtable tablecelleditor

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

NSIS - 如何在排除文件的同时递归复制?

我需要递归复制一个目录,但要在其中排除几个目录.

NSIS的文档说File命令采用/r和/x参数,但我无法使它们正常工作.

包含我的.nsi脚本的目录结构是:

parent-dir
    dir-to-exclude-1
        setup.nsi
    dir-to-copy-1
    dir-to-copy-2
    dir-to-copy-3
    dir-to-exclude-2
Run Code Online (Sandbox Code Playgroud)

我尝试了以下内容,但它对我不起作用:

SetOutPath $INSTDIR
File /r "..\**" /x "..\dir-to-exclude-1\**" /x "..\dir-to-exclude-2\**"  
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助.

编辑: 我越来越近,所以现在我有:

File /r /x \dir-to-exclude-1\*.* /x \dir-to-exclude-2\*.*  ..\*
Run Code Online (Sandbox Code Playgroud)

现在它将编译并安装所有文件,但不排除我想要的目录.有关如何排除这些内容的任何指导?

installer nsis

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

服务器需要客户端证书时如何使用wsimport?

我有一个使用相互SSL身份验证的Web服务.当我安装了客户端证书时,我可以在浏览器中正常访问它.

我需要能够使用它wsimport来生成访问服务的Java代码.

如何设置我的凭据以便我可以使用wsimport?

这是我正在尝试的一个例子,但由于无法进行身份验证而超时.

wsimport ./sample.wsdl -p com.company.ws.sample -Xnocompile -d ./src -extension -keep -XadditionalHeaders

谢谢你的帮助

编辑:

这就是wsimport印刷品.WSDL绝对有效,在给定的位置,这是一个确定如何传递我的凭据进行身份验证的问题:

wsimport https://wsdl.location.com?WSDL -p com.company.ws.sample -Xnocompile 
-d ./src -extension -keep -XadditionalHeaders


parsing WSDL...

[ERROR] Received fatal alert: handshake_failure

Failed to read the WSDL document: "https://wsdl.location.com?WSDL", because 1) could 
not find the document; /2) the document could not be read; 3) the root element of 
the document is not <wsdl:definitions>.

[ERROR] failed.noservice=Could not find wsdl:service in the provided WSDL(s): …
Run Code Online (Sandbox Code Playgroud)

java web-services jax-ws wsimport

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