开发者

Netbeans annotation error

开发者 https://www.devze.com 2022-12-22 10:37 出处:网络
NetBeans do not accept my code. Why?开发者_如何学Go See the pic.You need to import the annotations you\'re using.

NetBeans do not accept my code. Why?开发者_如何学Go See the pic.


You need to import the annotations you're using.

E.g, import org.whatever.package.contains.ServiceProvider;


import {package}.ServiceProvider;


You need to change the code from

package org.demo.myfilter;

import org.demo.textfilter.TextFilter;

@ServiceProvider(service=TextFilter.class)
public class UpperCaseFilter implements TextFilter {

    public String process(String s) {
        return s.toUpperCase();
    }

}

into

package org.demo.myfilter;

import org.demo.textfilter.TextFilter;
import org.openide.util.lookup.ServiceProvider;

@ServiceProvider(service=TextFilter.class)
public class UpperCaseFilter implements TextFilter {

    public String process(String s) {
        return s.toUpperCase();
    }

}

Note: You can leverage the Fix Imports item from the Source menu (CTRL-SHIFT-I/Clover-SHIFT-I) to take care of the second one automatically, if you have declared the dependeny between your module and the NetBeans platform Utilities API module


Perhaps you are missing an import. Can you import "ServiceProvider"? It's hard to know for sure without know more about your project setup, but that's my first guess.

0

精彩评论

暂无评论...
验证码 换一张
取 消