小编hav*_*ked的帖子

为什么这个对象的"forEach不是函数"?

这可能是非常愚蠢的事情,但我不明白为什么这不起作用.

var a = {"cat":"large"};

a.forEach(function(value, key, map){
    console.log(value);
});
Run Code Online (Sandbox Code Playgroud)

未捕获的TypeError:a.forEach不是函数

http://jsfiddle.net/ty7z6pse/

javascript foreach object

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

Maven属性未按预期评估(os-maven-plugin)

我有一个带有模块的父项目。其中一个模块在其pom文件中声明以下内容:

...
<build>
    <extensions>
        <extension>
            <groupId>kr.motd.maven</groupId>
            <artifactId>os-maven-plugin</artifactId>
            <version>1.2.3.Final</version>
        </extension>
    </extensions>
</build>
...
<dependencies>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-tcnative</artifactId>
        <version>${netty.tcnative.version}</version>
        <classifier>${os.detected.classifier}</classifier>
    </dependency>
</dependencies>    
...
Run Code Online (Sandbox Code Playgroud)

mvn package从父项目运行时,该项目将成功构建。然后,我想将此子模块项目用作其他gradle项目中的依赖项,因此我将父项目安装到我的maven本地仓库中,并在build.gradle文件中声明该依赖项。

在构建gradle项目时,我遇到此错误:

Could not resolve all dependencies for configuration ':runtime'.
> Could not find netty-tcnative-${os.detected.classifier}.jar (io.netty:netty-tcnative:1.1.33.Fork2).
    Searched in the following locations: https://repo.grails.org/grails/core/io/netty/netty-tcnative/1.1.33.Fork2/netty-tcnative-1.1.33.Fork2-${os.detected.classifier}.jar
Run Code Online (Sandbox Code Playgroud)

为什么${os.detected.classifier}不进行评估?应该注意的是,${netty.tcnative.version}它被评估为在父pom中定义的属性,因为它出现在所寻求的jar路径中。

谢谢。

编辑:我认为问题可能是因为gradle引用了依赖项,并且没有调用maven来执行os-maven-plugin,后者评估表达式。只是一个猜测。

java gradle pom.xml maven

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

java.nio transferTo似乎不可能快?

有人可以解释一下该transferTo方法如何以看似1000+ MB /秒的速度复制文件.我使用372MB二进制文件运行了一些测试并且第一个副本很慢,但如果我更改输出名称并再次运行它,输出目录中会出现一个额外的文件,只需180ms,超过2000 MB /秒.这里发生了什么?我正在运行Windows 7.

private static void doCopyNIO(String inFile, String outFile) {
    FileInputStream     fis = null;
    FileOutputStream    fos = null;
    FileChannel         cis = null;
    FileChannel         cos = null;

    long                len = 0, pos = 0;

    try {
        fis = new FileInputStream(inFile);
        cis = fis.getChannel();
        fos = new FileOutputStream(outFile);
        cos = fos.getChannel();
        len = cis.size();
        while (pos < len) {
            pos += cis.transferTo(pos, (1024 * 1024 * 10), cos);    // 10M
        }
        fos.flush();
    } catch (Exception e) …
Run Code Online (Sandbox Code Playgroud)

java nio

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

标签 统计

java ×2

foreach ×1

gradle ×1

javascript ×1

maven ×1

nio ×1

object ×1

pom.xml ×1