Spring Framework Tutorial

Software Setup and Configuration (STS/Eclipse/IntelliJ)

Core Spring

Spring Annotations

Spring Data

Spring JDBC

Spring Security

How to Turn on Code Suggestion in Eclipse or Spring Tool Suite?

Code suggestions (or code completion) are invaluable for speeding up the development process, helping with API discovery, and reducing typos. In Eclipse and the Spring Tool Suite (STS, which is built on top of Eclipse), this feature is termed "Content Assist."

To ensure that Content Assist (code suggestion) is enabled and to configure it:

  1. Open Preferences:

    • Go to Window > Preferences if you're on Windows or Linux.
    • If you're on a Mac, it's Eclipse or STS > Preferences.
  2. Navigate to Content Assist Settings:

    • In the Preferences dialog, go to Java > Editor > Content Assist.
  3. Auto Activation:

    • To make Content Assist more proactive, you can enable and configure "Auto Activation." This means that suggestions will pop up automatically as you type, without needing to manually trigger them.
    • Check the box for Enable auto activation.
    • You can set the auto activation delay (in milliseconds). A lower number will make suggestions appear more quickly as you type.
    • The Auto activation triggers for Java field defines which characters trigger the content assist. By default, this is set to .abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ, which means the suggestions will pop up when you type any of those characters. You can modify this to suit your preferences.
  4. Triggering Content Assist Manually:

    • While you're typing, you can manually trigger content assist by pressing Ctrl + Space (on most configurations). If Content Assist doesn't appear when you expect it to, ensure that this key combination is correctly set:
      • In the Preferences dialog, navigate to General > Keys.
      • In the search box, type "Content Assist." This will filter the list of key bindings.
      • Check the binding for "Content Assist" in the list and modify it if necessary.
  5. Additional Suggestions:

    • Back in the Java > Editor > Content Assist section, you can click on the Advanced button to configure which types of suggestions you want to be shown and in which order. Here, you can ensure that classes, templates, keywords, etc., are all included in the Content Assist suggestions.
  6. Save & Close:

    • Click Apply and then OK to save any changes and close the Preferences dialog.

With these settings, Content Assist should aid you effectively while coding in Eclipse or STS. If you're still facing issues, consider resetting your Eclipse/STS workspace or creating a new workspace, as sometimes configurations can get muddled in complex projects.