1

I'm playing around with spring boot, learning spring framework and different libraries like lombok. The problem is that there are no annotation descriptions shown in my IDE (IntellijIDEA Ultimate Edition) when I press Alt + Q or hover mouse over it like in this video. Window pops up, but I see only class / interface basic information.

For example annotation @Service description:

org.springframework.stereotype @Target({ElementType.TYPE}) 
@Retention(RetentionPolicy.RUNTIME) 
@Documented 
@Component 
public interface Service
extends annotation.Annotation
Maven: org.springframework:spring-context:

@Data annotation from video:

lombok @Target({ElementType.TYPE}) 
@Retention(RetentionPolicy.SOURCE) 
public interface Data
extends annotation.Annotation
Maven: org.projectlombok:lombok:1.18.20

How to turn descriptions on ? It helps me to explore annotations without the need to open web browser and I think that it would just be useful in the future.

P.S. It shows me descriptions of methods (System.out.println(), exception.getMessage(), etc.)

denh
  • 179
  • 1
  • 1
  • 8
  • Do you use Maven or Gradle project? Make sure to download the sources for the libraries you are using in the project to get the quick documentation working. – CrazyCoder May 24 '21 at 17:27
  • @CrazyCoder, I'm using Maven. Do you mean to add dependencies ? I have them already, code is compiling successfully. – denh May 24 '21 at 19:03
  • 1
    Enable Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Importing | Sources or [click here](https://i.imgur.com/qPY0uJ5.png). – CrazyCoder May 24 '21 at 19:04
  • @CrazyCoder, thank you, it works. I had to press "Download sources" button like on the screenshot (Right panel -> Maven -> Download Sources) to download sources for already added libraries. Could you explain why it works like that ? Why I had to download sources ? I thought Maven already adds sources when dependecy is added. – denh May 24 '21 at 19:18
  • Maven and IntelliJ IDEA doesn't add sources automatically, it's a configuration option. See https://stackoverflow.com/questions/5780758/maven-always-download-sources-and-javadocs. – CrazyCoder May 24 '21 at 19:18

1 Answers1

3

Annotation documentation requires the sources for the libraries to be present. Maven and IntelliJ IDEA do not download the library sources automatically.

For IntelliJ IDEA enable Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Importing | Automatically download: Sources and reimport the project.

You can also download the sources manually from the Maven tool window.

Another option is to configure Maven to download sources automatically in pom.xml, see this answer for more details.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904