小编Ori*_*ski的帖子

Ant安装找不到maven-artifact-ant-2.0.4-dep.jar

我正在尝试使用这些说明在Windows 7上安装Ant ,但在第5阶段,当我运行命令时ant -f fetch.xml -Ddest=system,我收到以下错误:

Buildfile: C:\Program Files\WinAnt\fetch.xml
pick-dest:
[echo] Downloading to C:\Program Files\WinAnt\lib
probe-m2:
download-m2:
[echo] Downloading to C:\Program Files\WinAnt\lib
[get] Getting: http://ibiblio.org/maven2//org/apache/maven/maven-artifact-ant/2.0. /maven-artifact-ant-2.0.4-dep.jar
[get] To: C:\Program Files\WinAnt\lib\maven-artifact-ant-2.0.4-dep.jar
[get] Error opening connection java.io.FileNotFoundException: http://ibiblio.org/maven2//org/apache/maven/maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4-dep.jar
[get] Error opening connection java.io.FileNotFoundException: http://ibiblio.org/maven2//org/apache/maven/maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4-dep.jar
[get] Error opening connection java.io.FileNotFoundException: http://ibiblio.org/maven2//org/apache/maven/maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4-dep.jar
[get] Can't get http://ibiblio.org/maven2//org/apache/maven/maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4-dep.jar to C:\Program Files\WinAnt\lib\maven-artifact-ant-2.0.4-dep.jar
BUILD FAILED
C:\Program Files\WinAnt\get-m2.xml:85: Can't get http://ibiblio.org/maven2//org/apach/maven/maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4-dep.jar to C:\Program Files\WinAnt\lib\maven-artifact-ant-2.0.4-dep.jar
Total time: 1 second

我知道URL无法访问,因此我尝试将此URL输入浏览器,实际上它不存在.我找到了以下文件maven-artifact-ant-2.0.4-dep.jar:

http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/maven/maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4-dep.jar

代替.那么我该如何解决这个问题呢?

ant maven

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

Poco :: HttpClientSession.receiveResponse()抛出NoMessageException没有明显的原因

我用Poco用Java编写了HTTP服务器,并用C ++编写了客户端。这是C ++客户端代码的一部分:

URI uri("http://127.0.0.1:4444");
HTTPClientSession session(uri.getHost(), uri.getPort());

HTTPRequest req(HTTPRequest::HTTP_POST,
                "/pages/page",
                HTTPMessage::HTTP_1_1);

session.sendRequest(req);
HTTPResponse res;
std::istream &is = session.receiveResponse(res);
Run Code Online (Sandbox Code Playgroud)

在最后一行,我得到以下错误:

terminate called after throwing an instance of 'Poco::Net::NoMessageException'
  what():  No message received
Run Code Online (Sandbox Code Playgroud)

但是我不明白为什么。连接成功建立,请求的页面存在。我在已知的网站(例如Wikipedia)上尝试了相同的代码,并且没有任何异常。

我还尝试在命令行中使用cURL向我的服务器发出完全相同的请求,它显示了服务器的响应,因此服务器看起来不错。

这是服务器的原始响应,采用字符串形式:

"HTTP/1.1 200 OK\r\n" +
"Server: [server name]\r\n" +
"Content-Type: text/xml; charset=utf-8\r\n" +
"Content-Length:" + bodyBytes.length + "\r\n" +
"Resource: " + job.resId + "\r\n\r\n" + 
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><JobRequest><InputRepresentation id=\"0\"/>    <effectsList><cvtColor><code> CV_RGB2GRAY </code></cvtColor><resize><scaleFactorX> 0.5 </scaleFactorX><scaleFactorY> 0.5 </scaleFactorY><interpolation> INTER_LINEAR </interpolation></resize><GaussianBlur><kSize> 3 </kSize><sigmaX> 2 …
Run Code Online (Sandbox Code Playgroud)

c++ http poco-libraries

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

如何使用相对跳?

关于相对跳跃,我有以下问题:

  1. 我知道相对于当前PC而言,JMP SHORT <displacement>它将跃升至<displacement>字节。那是对的吗?
  2. 汇编器会自动生成相对跳转的操作码吗?即当我刚写时JMP <label>,如果该标签位于当前PC的128字节之内,它将产生一个相对跳转吗?
  3. 万一我想使用JMP SHORT <displacement>,计算位移的正确方法是什么?通过检查清单文件并计算偏移量?

x86 assembly nasm

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

使用"xs:any"获取"编译器无法遵守此javaType自定义"

我有以下xsd:

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

    <xs:element name="root">
        <xs:complexType>
            <xs:sequence>
                <xs:any processContents="skip" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

</xs:schema>
Run Code Online (Sandbox Code Playgroud)

以及以下绑定:

<jxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.1">
    <jxb:bindings schemaLocation="format.xsd">
        <jxb:bindings node="//xs:any">
            <jxb:property>
                <jxb:baseType>
                    <jxb:javaType name="org.w3c.dom.Element"
                     parseMethod="leif.ElementFormatter.parseElement"
                     printMethod="leif.ElementFormatter.printString" />
                </jxb:baseType>
            </jxb:property>
        </jxb:bindings>
    </jxb:bindings>
</jxb:bindings>
Run Code Online (Sandbox Code Playgroud)

但是当我运行xjc时......
xjc -p leif -b bindings.xml format.xsd

我收到以下错误:

parsing a schema...
[ERROR] compiler was unable to honor this javaType customization. It is attached to a wrong place, or its inconsistent with other bindings.
  line 9 of file:/C:/Users/leif/workspace/doughan/src/main/resources/bindings.xml

[ERROR] (the above customization is …
Run Code Online (Sandbox Code Playgroud)

java xml xsd jaxb xjc

5
推荐指数
0
解决办法
433
查看次数

关于printf参数的问题.C/C++

我们有以下代码片段:

char tab[2][3] = {'1', '2', '\0', '3', '4', '\0'};
printf("%s\n", tab);
Run Code Online (Sandbox Code Playgroud)

我不明白为什么我们在通话中没有收到错误/警告printf.我收到警告但没有错误,程序运行正常.它打印' 12'.
printf期待一个类型的参数char *,即指向char.所以,如果我声明char arr[3],那么arr是一个包含a的内存单元的地址char,所以如果我printf用它调用它会衰减指向char,即char *.
类似地,tab是包含3个字符的类型数组的存储器单元的地址,而存储器单元的地址包含char,因此tab将衰减char **,并且它应该是一个问题,因为printf期望a char *.

有人可以解释这个问题吗?

附录:

我得到的警告是:
a.c:6: warning: char format, different type arg (arg 2)

c c++ printf pointers matrix

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

工厂方法模式与组合模式

来自 GoF 关于工厂方法模式的章节:

定义一个用于创建对象的接口,但让子类决定实例化哪个类。工厂方法让类将实例化推迟到子类。

其思想是让子类决定实例化哪个类,而GoF对这一思想的实现,就是在超类中提供一个抽象方法,子类需要重写该方法,从而提供自己的实例化逻辑。

我不明白的是,为什么使用抽象方法来实现它,而不是使用作为工厂的类成员。我会解释一下。

这是 GoF 的方式:

public abstract class Creator {
    public void doStuff() {
        Product product = createProduct();
        /* etc. */
    }

    public abstract Product createProduct();
}
Run Code Online (Sandbox Code Playgroud)

用法:

    MyCreator myCreator = new Creator() {
        @Override
        public Product createProduct() {
            return new MyProduct();
        }
    }

    myCreator.doStuff();
Run Code Online (Sandbox Code Playgroud)

但为什么要费心子类化等呢?我建议这种方法:

public class Creator {
    private Factory factory;

    /* constructor */
    public Creator(Factory factory) {
        this.factory = factory;
    }

    public void doStuff() {
        Product product = factory.createProduct(); …
Run Code Online (Sandbox Code Playgroud)

java design-patterns factory-pattern

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

如何实现回退功能列表

假设我有一个返回的函数列表,Option[Int]我想返回第一个返回的结果Some(…),而不是计算它之后的其余函数。例如:

val list = List(
  () => { println("a"); None },
  () => { println("b"); Some(1) },
  () => { println("c"); Some(2) },
  () => { println("d"); None }
)
Run Code Online (Sandbox Code Playgroud)

在这种情况下,结果将是Some(1),并且它只会打印ab(因为其余的都没有计算)。

我的解决方案是

list.foldLeft(Option.empty[Int]) { (a, b) => a orElse b() }
Run Code Online (Sandbox Code Playgroud)

问题是否有更优雅/简洁的方法,或者一些图书馆?

scala

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

使用C/Linux指针到指针的分段错误

在下面的代码中我得到一个分段错误:

Set *getpar() {...}

char function(...) 
{
   Set **S;
   *S = getpar(); /* Segmentation Fault */
   ...
}
Run Code Online (Sandbox Code Playgroud)

但奇怪的是,几乎没有变化就没有分段错误:

Set *getpar() {...}
...
char function(...) 
{
   Set *S;       // One less '*'
   S = getpar(); // One less '*'
   ...
}
Run Code Online (Sandbox Code Playgroud)

据我所知,如果有一个' Set **S'那么*S是指向一个Set对象的指针,所以如果第二个代码工作正常,为什么不应该第一个?*S第一个代码相当于S第二个代码,我不对吗?我该如何解决这个问题?

c pointers segmentation-fault

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

为什么HashMap的get()在不应该返回时返回null?

我写了一个方法来检查一个字符串是否只有唯一的字符.我发送明显的非唯一字符字符串"11",它返回true而不是false.它发生的原因是get(c)if (tab.get(c) == null)返回中,null即使该字符'1'已经在HashMap中.

我该怎么做才能获得预期的行为?

/* Check if a string contains only unique characters */
public static boolean isUniqueChars(String s) {

    HashMap<Boolean, Character> tab = new HashMap<Boolean, Character>();
    Character c;

    for (int i = 0; i < s.length(); ++i) {
        c = new Character(s.charAt(i));
        if (tab.get(c) == null)
            tab.put(Boolean.TRUE, c);
        else
            return false;
    }
    return true;
}

public static void main(String[] args) {

    String s = …
Run Code Online (Sandbox Code Playgroud)

java hashmap

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

泛型方法和非泛型方法之间的区别

这两种方法有什么区别?

public <T extends Serializable, Y extends List<T>> void foo(Y y, T t);
Run Code Online (Sandbox Code Playgroud)

public void foo(Serializable ser, List<Serializable> list);
Run Code Online (Sandbox Code Playgroud)

java generics

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