Search code examples
javaspringeclipsemavenspring-tool-suite

Disable Eclipse to report "problems" on auto-generated classes (for example Q-classes)


Spring Tool Suite 4 Version: 4.19.0.RELEASE

Is there a way to configure STS4 / Eclipse to stop generating warnings in Problems view for auto-generated classes?

For example: "Unqualified access to the field QUser._super".

I don't want to turn of this type of warnings for the whole project or workspace because I want my classes to use qualified access and that warning hepls me except on auto-generated classes.

Below you can see the plugin I use to generate Q classes:


pom.xml

<!-- https://mvnrepository.com/artifact/com.mysema.maven/apt-maven-plugin -->
<plugin>
    <groupId>com.mysema.maven</groupId>
    <artifactId>apt-maven-plugin</artifactId>
    <version>${apt-maven-plugin.version}</version>
    <executions>
        <execution>
            <goals>
                <goal>process</goal>
            </goals>
            <configuration>
                <outputDirectory>target/generated-sources/java</outputDirectory>
                <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
            </configuration>
        </execution>
    </executions>
</plugin>

enter image description here


Solution

  • This isn't perfect, as you'd need to rerun it if you regenerate your sources, but you can invoke the Clean Up functionality at the project or source folder level from inside the Package Explorer view to alter the Member Accesses in those sources. First, go to the Java -> Code Style -> Clean Up preference page, then when you've right-clicked on the source folder, you'll find the Clean Up... action in the Source submenu.