小编Gar*_*lon的帖子

如何查看GitHub拉取请求?

我想查看以前创建的拉取请求(通过GitHub Web界面创建).我搜索并找到了refs/pull或refs/pull/pr的不同地方

但是当我添加fetch = +refs/pull/*/head:refs/remotes/origin/pr/*到git配置文件并执行git fetch时

我做错了什么?GitHub应该自动创建pull/xyz的东西,还是我必须配置一些东西?

git github git-checkout pull-request

205
推荐指数
13
解决办法
9万
查看次数

为什么我需要一个用于自动装配/注入字段的setter?

我有一个豆子:

    <bean id="BasketLogic" class="efco.logic.EfcoBasketLogic" autowire="byType">
        <property name="documentLogic" ref="DocumentLogic" />
        <property name="stateAccess" ref="StateAccess" />
        <property name="contextAccess" ref="ContextAccess" />
    </bean>

  <bean id="EfcoErpService" autowire="byType" class="efco.erp.service.EfcoErpServiceImpl">
    <constructor-arg ref="ErpConnector"/>
  </bean>
Run Code Online (Sandbox Code Playgroud)

documentLogic,stateAccesscontextAccess上田BasketLogicImpl

我没有 <context:component-scan />

EfcoBasketLogic.java:

public class EfcoBasketLogic extends BasketLogicImpl {

        @Inject
        private EfcoErpService erpService;
    ...
    ...
    ...
}
Run Code Online (Sandbox Code Playgroud)

erpService为null,除非我提供setter.但为什么?我认为在自动装配发生的地方不需要安装器?可能是BasketLogicImpl对此负责吗?

setter spring inject autowired

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

无法从伴随对象访问伴随类的方法

我以为我可以从我的伴侣对象访问伴侣类的每个方法.但我不能?

class EFCriteriaType(tag:String) extends CriteriaType
{
  // implemented method of CriteriaType
  def getTag = this.tag   
}

object EFCriteriaType
{
  var TEXT: CriteriaType = new EFCriteriaType("text")

  override def toString = getTag
}
Run Code Online (Sandbox Code Playgroud)

编译器错误:找不到:值getTag

我做错了什么?

methods scala object

8
推荐指数
2
解决办法
9515
查看次数

如果删除了组件扫描,则@Autowired不起作用

我面临的问题是,如果从配置中删除组件扫描标记,注释@Autowired将不再起作用(在所有使用此批注的Java类中)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

  <context:component-scan base-package="efco.auth" />

here are some beans...
Run Code Online (Sandbox Code Playgroud)

efco.auth包中只有一个类,这个类与以下类EfcoBasketLogic无关.

和一个使用@Autowired的类:

package efco.logic;
    public class EfcoBasketLogic extends BasketLogicImpl {

        @Autowired
        private EfcoErpService erpService;
Run Code Online (Sandbox Code Playgroud)

这个Bean在另一个spring配置文件中定义:

<bean id="BasketLogic" class="efco.logic.EfcoBasketLogic">
    <property name="documentLogic" ref="DocumentLogic" />
    <property name="stateAccess" ref="StateAccess" />
    <property name="contextAccess" ref="ContextAccess" />
  </bean>
Run Code Online (Sandbox Code Playgroud)

如您所见,未定义erpService.其他三个属性在BasketLogicImpl上并且有setter.

我做错了什么?

spring explicit autowired

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

Scala,无法实现泛型java方法

我想实现一个在scala中使用泛型的java方法(2.9.2).但是我失败了......

Java接口方法:

public <T extends Number> void setAttribute(Key<T> key, Number value);
Run Code Online (Sandbox Code Playgroud)

想要实现该方法的Scala代码:

def setAttribute[T <: Number](key: Key[T], value: Number) = {
  setAttributeLocal(key, value)  }

private def setAttributeLocal[T](key: Key[T], value: T) = {
  val stringValue = ConvertUtils.convert(value, classOf[String]).asInstanceOf[String]
  session = session + (key.getValue() -> stringValue)
}
Run Code Online (Sandbox Code Playgroud)

关键看起来像:

public class Key<T>
Run Code Online (Sandbox Code Playgroud)

但这不编译.

[error]  found   : mypackage.Key[T]
[error]  required: mypackage.Key[java.lang.Number]
[error] Note: T <: java.lang.Number, but Java-defined class Key is invariant in type T.
[error] You may wish to investigate a wildcard type …
Run Code Online (Sandbox Code Playgroud)

java generics methods scala implements

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

在 Intellij IDEA 13 的 diff 中启用显示行分隔符的差异

我正在使用 IDEA 13.0.1。由于某些行分隔符的原因,单元测试失败。但是当我尝试比较两个结果时,IDEA 说“内容仅在行分隔符上有差异”。

我找不到可以向我展示这些差异的设置。有吗?

diff newline intellij-idea

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

在里面等待还是在外面期待?

有什么区别:

it('should blabla', async () => {
    await expect(callThatReturnsAPromise()).toBe(false);
});
Run Code Online (Sandbox Code Playgroud)

和:

it('should blabla', async () => {
    expect(await callThatReturnsAPromise()).toBe(false);
});
Run Code Online (Sandbox Code Playgroud)

那么,await 是在expect 函数外部还是内部呢?

如果 toBe 内部的调用也返回一个 Promise,我应该使用哪个版本?

it('should blabla', async () => {
    await expect(callThatReturnsAPromise()).toBe(callThatReturnsAPromise2());
});
Run Code Online (Sandbox Code Playgroud)

或者:

 it('should blabla', async () => {
     expect(await callThatReturnsAPromise()).toBe(await callThatReturnsAPromise2());
 });
Run Code Online (Sandbox Code Playgroud)

那么,在期望之外等待会解决所有承诺,还是我必须在函数内等待每一个承诺?

好的,我用这段代码进行了测试:

let a = function() {
        console.log('huba');
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve(42);
            }, 5000);
        });
    };

    let b = function() {
        console.log('buba');
        return new Promise((resolve, reject) => …
Run Code Online (Sandbox Code Playgroud)

javascript promise async-await jasmine

6
推荐指数
0
解决办法
818
查看次数

IDEA 不显示所有可以合并的分支

我想通过菜单“VCS -> Git -> Merge Changes”与 Intellij IDEA (11.1.3) 合并。但是缺少所需的分支 (mergeRequest15)。但为什么?是不是因为这个分支似乎基于另一个分支(mergeRequest14)?

gitk --all 显示:

gitk --all IDEA 显示:

IDEA 合并分支

git merge branch intellij-idea

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

自定义转换器上的Dozer,InstantiationException

我写了自己的客户转换器:

public class MyFancyCustomConverter extends DozerConverter<Integer, AnObject>
{
    public MyFancyCustomConverter(Class<Integer> prototypeA, Class<AnObject> prototypeB)
    {
        super(prototypeA, prototypeB);
    }

    @Override
    public AnObject convertTo(Integer source, AnObject destination)
    {
        // TODO: do something
        return null;
    }

    @Override
    public Integer convertFrom(AnObject source, Integer destination)
    {
        // TODO: do something
        return 0;
    }
}
Run Code Online (Sandbox Code Playgroud)

我的mapping.xml:

<mapping>
    <class-a>java.lang.Integer</class-a>
    <class-b>xyz.AnObject</class-b>
    <field custom-converter="xyz.MyFancyCustomConverter" custom-converter-param="hello">
      <a>this</a>
      <b key="my.key">this</b>
    </field>
</mapping>
Run Code Online (Sandbox Code Playgroud)

但是我得到了这个例外:

org.dozer.MappingException:java.lang.InstantiationException:xyz.MyFancyCustomConverter

知道我做错了什么吗?我想这是因为MyFancyCustomConverter没有默认转换器.但我不能添加一个,因为DozerConverter没有...

mapping converter dozer instantiationexception

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

xyz不在类型变量T的范围内

我有以下课程:

public class Blub extends AbstractPreloadDefinition<AddressmasterModel>
Run Code Online (Sandbox Code Playgroud)

javac编译器给我以下错误:

错误:(15,79)java:type参数AddressmasterModel不在类型变量T的范围内

AbstractPreloadDefinition 看起来如下:

abstract class AbstractPreloadDefinition<T extends PersistedEntity<?>> implements PreloadDefinition<T>
Run Code Online (Sandbox Code Playgroud)

并且AddressmasterModel看起来如下:

public abstract class AddressmasterModel<V extends VoucherModel> implements Serializable, Auditable, PersistedEntity<Integer>, Comparable<AddressmasterModel<V>> 
Run Code Online (Sandbox Code Playgroud)

所以,AddressmasterModel实现PersistedEntity.哪里出错?我找不到:/

我正在使用IntelliJ 2017.1javac作为编译器.如果我作为编译器切换到eclipse,这个错误就消失了......

java generics type-variables

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

在@Shared 或 setupSpec() 中初始化对象

有什么区别:

@Shared
MyObject myObject = new MyObject()
Run Code Online (Sandbox Code Playgroud)

MyObject myObject

def setupSpec() {
    myObject = new MyObjec()
}
Run Code Online (Sandbox Code Playgroud)

为什么要在第二个示例中使用 @Shared 注释?两者都只创建一次,不是吗?

shared initialization spock

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

动态提取元组值

有没有办法如何在飞行中从元组中提取值?

让我们假设元组:

val x = ("1", 2, "3")
Run Code Online (Sandbox Code Playgroud)

和方法:

def doFoo(value1: String, value2: Int, value3: String)={}
Run Code Online (Sandbox Code Playgroud)

如何用元组'x' 调用doFoo()?像doFoo(x)这样的东西,并且动态提取元组中的值以匹配方法签名.

scala tuples extract on-the-fly

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