简体   繁体   中英

Javac cannot find symbol error when there is a dependency

I am getting the following error - sorry if this is fairly basic, I'm not super experienced with Java.

javac -cp "/Users/myname/Desktop/Projects/Project/build_dir/jarname.jar" filename.java

filename.java:24: error: cannot find symbol
@JsonDeserialize(builder = Builder.class)
                           ^
  symbol: class Builder

Ok, so far so good.

So I look into the code of filename.java, and see this on line 24:

@JsonDeserialize(builder = Builder.class)

So I've got a deserialize annotation, for the builder class (I think).

However, in the same file, filename.java, there IS a builder class:

   @JsonPOJOBuilder
    public static class Builder {

So what's going on here? Is it just that it's trying to compile and doesn't know to look for the Builder class too? How do I let Javac "know" that there is also a builder class?

Again, sorry if this is a basic question, but I'm not finding much information on the internet about it.

EDIT: As there's some question on how the application works, I'm including more code below:

@JsonInclude(value = JsonInclude.Include.NON_NULL)
@JsonDeserialize(builder = Builder.class)
public class DetailClass {
private DetailClass(Builder builder) {
...
}
...
@JsonPOJOBuilder
    public static class Builder {
...
}
}

So the Builder class is a method of the DetailClass as far as I can tell.

Looks like Builder is an inner class. To point to the inner class you should add parent class name before:

@JsonDeserialize(builder = Builder.class) -> @JsonDeserialize(builder = DetailClass.Builder.class)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM