I am trying to inject a property which is defined in server.env
.
@Inject
@ConfigProperty(name = "property")
private String serverProperty;
content of server.env
property=server-env-property
I have added it inside pom.xml
<serverEnv>src/main/liberty/config/server.env</serverEnv>
It is read during liberty-maven-plugin:2.2:package-server
CWWKM2144I: Update server configuration file server.env from /Users/abalaniuc/code/config/src/main/liberty/config/server.env.
However when application is executed I got this error:
The property property was not found in the configuration.
Stack trace:
[ERROR ] CWMCG5003E: The [BackedAnnotatedField] @Inject @ConfigProperty private com.microprofile.study.config.config.ConfigTestController.serverProperty InjectionPoint dependency was not resolved. Error: java.util.NoSuchElementException: CWMCG0015E: The property property was not found in the configuration.
at com.ibm.ws.microprofile.config.impl.AbstractConfig.getValue(AbstractConfig.java:175)
at [internal classes]
Obviously I am missing something, but can't figure out what exactly. Can you please help me?
As was suggested in the answers below, I have removed .
from a property name, but still getting same result.
Liberty-plugin configuration:
<plugin>
<groupId>net.wasdev.wlp.maven.plugins</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>${openliberty.maven.version}</version>
<executions>
<execution>
<id>package-server</id>
<phase>package</phase>
<goals>
<goal>create-server</goal>
<goal>install-apps</goal>
<goal>package-server</goal>
</goals>
<configuration>
<outputDirectory>target/wlp-package</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<assemblyArtifact>
<groupId>io.openliberty</groupId>
<artifactId>openliberty-runtime</artifactId>
<version>${openliberty.version}</version>
<type>zip</type>
</assemblyArtifact>
<configFile>src/main/liberty/config/server.xml</configFile>
<serverEnv>src/main/liberty/config/server.env</serverEnv>
<bootstrapPropertiesFile>src/main/liberty/config/bootstrap.properties</bootstrapPropertiesFile>
<appArchive>${project.build.directory}/${final.name}.war</appArchive>
<packageFile>${project.build.directory}/${final.name}.jar</packageFile>
<include>runnable</include>
<serverName>${final.name}</serverName>
<installAppPackages>project</installAppPackages>
</configuration>
</plugin>
To start application I do:
mvn clean package
java -jar target/config.jar