GWTP&独生子

时间:2015-04-21 19:12:22

标签: maven gwt singleton gwtp

我有简单的主持人。宣布对单身人士的调用

private RandomString randomString = RandomString.getInstance();

组装maven时我有错误

[INFO]             [ERROR] Error injecting by.gwttest.client.client.application.packet.PacketPagePresenter$MyProxy: Unable to create or inherit binding: No @Inject or default constructor found for by.gwttest.client.client.application.packet.PacketPagePresenter$MyProxy
[INFO]   Path to required node:
[INFO] 
[INFO] by.gwttest.client.client.application.packet.PacketPagePresenter$MyProxy [com.gwtplatform.mvp.client.gin.AbstractPresenterModule.bindPresenter(AbstractPresenterModule.java:121)]
[INFO] 
[INFO]             [ERROR] Error injecting by.gwttest.client.client.application.packet.PacketPageView$Binder: Unable to create or inherit binding: No @Inject or default constructor found for by.gwttest.client.client.application.packet.PacketPageView$Binder
[INFO]   Path to required node:
[INFO] 
[INFO] by.gwttest.client.client.application.packet.PacketPageView [com.gwtplatform.mvp.client.gin.AbstractPresenterModule.bindPresenter(AbstractPresenterModule.java:120)]
[INFO]  -> by.gwttest.client.client.application.packet.PacketPageView$Binder [@Inject constructor of by.gwttest.client.client.application.packet.PacketPageView]
[INFO] 
[INFO]    [ERROR] Errors in 'gen/com/gwtplatform/mvp/client/DesktopGinjectorProvider.java'
[INFO]       [ERROR] Line 8: Failed to resolve 'com.gwtplatform.mvp.client.DesktopGinjector' via deferred binding

RandomString ...

    private RandomString() {

    }

    private static class RandomStringHolder {
        private final static RandomString instance = new RandomString();
    }

    public static RandomString getInstance() {
        return RandomStringHolder.instance;
    }
...

可以连接什么?没有声明RandomString项目

2 个答案:

答案 0 :(得分:0)

您的错误与RandomString无关。该错误表明您缺少@Inject带注释的构造函数。

确保您的PacketPageViewPacketPagePresenter有一个使用@Inject注释的空构造函数。

@Inject
public PacketPagePresenter() {
}

答案 1 :(得分:0)

此代码中出现错误

private String convertMStoTime(long millis) {
    //return null;
     return String.format(
     "%02d:%02d:%02d",
     TimeUnit.MILLISECONDS.toHours(millis),
     TimeUnit.MILLISECONDS.toMinutes(millis)
     - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
     .toHours(millis)),
     TimeUnit.MILLISECONDS.toSeconds(millis)
     - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
     .toMinutes(millis)));
}

TimeUnit在GWT中没有发现