Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Property Completion using @ConfigurationProperties #458

Closed
hannah23280 opened this issue May 7, 2020 · 1 comment
Closed

No Property Completion using @ConfigurationProperties #458

hannah23280 opened this issue May 7, 2020 · 1 comment

Comments

@hannah23280
Copy link

vscode version: 1.44.2
Spring Boot Tools extensions:1.17.0

Hi, I am currently using @ConfigurationProperties from spring boot. Despite that my gradle has generated build folder containing spring-configuration-metadata.json (located at build\classes\java\main\META-INF) in it, I am still not able to get any property completion in the properties file.

below is the content of my spring-configuration-metadata.json

{
  "groups": [
    {
      "name": "otp",
      "type": "com.apress.demo.MyAppProperties",
      "sourceType": "com.apress.demo.MyAppProperties"
    }
  ],
  "properties": [
    {
      "name": "otp.enabled",
      "type": "java.lang.String",
      "sourceType": "com.apress.demo.MyAppProperties"
    }
  ],
  "hints": []
}

Am I missing anything?

@kdvolder
Copy link
Member

kdvolder commented May 7, 2020

located at build\classes\java\main\META-INF

I think that is the problem here. This 'build' folder is where a gradle commandline build produces its output. However, this is separate from Eclipse's build path. Eclipse produces output instead into the bin folder.

We can see that when open a typical Spring boot gradle project's .classpath file:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" output="bin/main" path="src/main/java">
		<attributes>
			<attribute name="gradle_scope" value="main"/>
			<attribute name="gradle_used_by_scope" value="main,test"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="src" output="bin/main" path="src/main/resources">
		<attributes>
			<attribute name="gradle_scope" value="main"/>
			<attribute name="gradle_used_by_scope" value="main,test"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="src" output="bin/test" path="src/test/java">
		<attributes>
			<attribute name="gradle_scope" value="test"/>
			<attribute name="gradle_used_by_scope" value="test"/>
			<attribute name="test" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
	<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
	<classpathentry kind="output" path="bin/default"/>
</classpath>

Notice how all output folder refer to paths of the form bin/XXX rather than build/XXX.

Not sure if there is much we can do about it or even if we should. My take on it is that this is probably something for BuildShip to fix. BuildShip would need to integrate somehow with Eclipse JDT APT (APT = Annotation Processing Tool). BuildShip should configure JDT APT so that the spring boot annotation processor is executed as part of the Eclipse build. This would produce the configuration metadata into an output folder that is part of the Eclipse buildpath, and then STS will pick up on the this file and parse it. Right now, STS does not, because the file, while it may exist, is not actually on the Eclipse buildpath so our tooling doesn't consider it as relevant.

The issue of integrating annotation processor with BuildShip is a long standing one. You can find it here: eclipse-buildship/buildship#329

I'm going to close this issue as I don't think it is an STS issue.

@kdvolder kdvolder closed this as completed May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants