We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I can't inject complex configuration into any class. Using Java 17.
I get this error when resolving MessagePublisher.java:
MessagePublisher.java
No configuration setting found for key 'rabbitmq'
My suspicion as that is has to do with the how the JSON is being read.
pom.xml:
pom.xml
<dependency> <groupId>com.google.inject</groupId> <artifactId>guice</artifactId> <version>5.0.1</version> </dependency> <dependency> <groupId>net.jmob</groupId> <artifactId>guice.conf</artifactId> <version>v1.5.0</version> </dependency>
In BasicModule.java:
BasicModule.java
install(new ConfigurationModule() .fromPath(new File("/mypath")));
app.java:
app.java
@BindConfig(value = "app", syntax = Syntax.JSON) public final class App { private static final int DEFAULT_RETENTIONTIMEDAYS = 2555; private MessagePublisher messagePubisher; @InjectConfig private Optional<Integer> retentionTimeDays; @Inject private App(MessagePublisher messagePubisher) { this.customerRetriever = customerRetriever; this.messagePubisher = messagePubisher; } }
MessagePublisher.java:
@BindConfig(value = "app", syntax = Syntax.JSON) public class MessagePublisher { @InjectConfig("rabbitmq") RabbitMQConnectionConfiguration configuration; }
Assuming this app.json:
app.json
{ "retentionTimeDays": 2000, "db": { "host": "localhost", "port": 3306, "database": "mydb", "user": "root", "password": "blah" }, "rabbitmq": { "host": "localhost", "port": 1, "vhost": null, "exchange": "log" } }
public interface RabbitMQConnectionConfiguration { String getHost(); int getPort(); String getVhost(); String getExchange(); }
public interface DbConnectionConfiguration { String getHost(); Optional<Integer> getPort(); String getDatabase(); String getUser(); String getPassword(); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I can't inject complex configuration into any class. Using Java 17.
I get this error when resolving
MessagePublisher.java
:No configuration setting found for key 'rabbitmq'
My suspicion as that is has to do with the how the JSON is being read.
pom.xml
:In
BasicModule.java
:app.java
:MessagePublisher.java
:Assuming this
app.json
:The text was updated successfully, but these errors were encountered: