How do I read application properties in Micronaut?
I integrated AWS SES API to my Micronaut Groovy application using guide send mail in micronaut and I am able send mails if I directly assign values to properties.
I want to make it config driven hence have been trying to find ways to achieve that.
I tried @Value annotation as mentioned in guide but was not able to make it work.
@Value("aws.secretkeyid")
String keyId
Further digging into documentation revealed that Micronaut has its own annotation for injecting properties in variables.
@Property(name="aws.secretkeyid")
String keyId
But nothing seems to work, my variables are still null.
What could be possibly wrong here ?
For reference, following is in my application.yml file
aws:
keyid: "2weadasdwda"
secretkeyid: "abcdesdasdsddddd"
region: "us-east-1"
micronaut
add a comment |
I integrated AWS SES API to my Micronaut Groovy application using guide send mail in micronaut and I am able send mails if I directly assign values to properties.
I want to make it config driven hence have been trying to find ways to achieve that.
I tried @Value annotation as mentioned in guide but was not able to make it work.
@Value("aws.secretkeyid")
String keyId
Further digging into documentation revealed that Micronaut has its own annotation for injecting properties in variables.
@Property(name="aws.secretkeyid")
String keyId
But nothing seems to work, my variables are still null.
What could be possibly wrong here ?
For reference, following is in my application.yml file
aws:
keyid: "2weadasdwda"
secretkeyid: "abcdesdasdsddddd"
region: "us-east-1"
micronaut
add a comment |
I integrated AWS SES API to my Micronaut Groovy application using guide send mail in micronaut and I am able send mails if I directly assign values to properties.
I want to make it config driven hence have been trying to find ways to achieve that.
I tried @Value annotation as mentioned in guide but was not able to make it work.
@Value("aws.secretkeyid")
String keyId
Further digging into documentation revealed that Micronaut has its own annotation for injecting properties in variables.
@Property(name="aws.secretkeyid")
String keyId
But nothing seems to work, my variables are still null.
What could be possibly wrong here ?
For reference, following is in my application.yml file
aws:
keyid: "2weadasdwda"
secretkeyid: "abcdesdasdsddddd"
region: "us-east-1"
micronaut
I integrated AWS SES API to my Micronaut Groovy application using guide send mail in micronaut and I am able send mails if I directly assign values to properties.
I want to make it config driven hence have been trying to find ways to achieve that.
I tried @Value annotation as mentioned in guide but was not able to make it work.
@Value("aws.secretkeyid")
String keyId
Further digging into documentation revealed that Micronaut has its own annotation for injecting properties in variables.
@Property(name="aws.secretkeyid")
String keyId
But nothing seems to work, my variables are still null.
What could be possibly wrong here ?
For reference, following is in my application.yml file
aws:
keyid: "2weadasdwda"
secretkeyid: "abcdesdasdsddddd"
region: "us-east-1"
micronaut
micronaut
asked Nov 22 at 17:55
Aditya Thakur
162112
162112
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You are using it incorrectly, you are injecting the literal value aws.secretkeyid
, not the value of a variable.
The correct syntax is:
@Value('${aws.secretkeyid}')
String keyId
Notice that you must use single quotes to avoid Groovy to attempt interpolation
The syntax you mentioned is for Java, not for Groovy. I tried it first thing as it was in [send mail in micronaut] documentation, but code does not even compile if you use above syntax.
– Aditya Thakur
Nov 23 at 11:05
1
The syntax I posted is for Groovy and does compile indeed. Notice that you must use single quotes to avoid Groovy to attempt interpolation.
– Álvaro Sánchez-Mariscal
Nov 23 at 11:10
1
Indeed you are right, I made the mistake of using double quotes instead of single quotes. Although due to this silly mistake at my end, I ended up upgrading Micronaut version to 1.0.1 and used @Property(name = "aws.secretkeyid") :D
– Aditya Thakur
Nov 23 at 18:06
I was going to answer it myself but your answer is correct as per the question. :)
– Aditya Thakur
Nov 23 at 18:07
add a comment |
If anyone else stumbles upon this problem, you also have alternative to use @Property annotation in Micronaut ( starting from version 1.0.1 )
Syntax is as follows
@Property(name = "your.application.property")
String propertyName
PS : This is what was mentioned in Micronaut Documentation but was not working in my case as I was on Micronaut Version 1.0.0
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53436144%2fhow-do-i-read-application-properties-in-micronaut%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You are using it incorrectly, you are injecting the literal value aws.secretkeyid
, not the value of a variable.
The correct syntax is:
@Value('${aws.secretkeyid}')
String keyId
Notice that you must use single quotes to avoid Groovy to attempt interpolation
The syntax you mentioned is for Java, not for Groovy. I tried it first thing as it was in [send mail in micronaut] documentation, but code does not even compile if you use above syntax.
– Aditya Thakur
Nov 23 at 11:05
1
The syntax I posted is for Groovy and does compile indeed. Notice that you must use single quotes to avoid Groovy to attempt interpolation.
– Álvaro Sánchez-Mariscal
Nov 23 at 11:10
1
Indeed you are right, I made the mistake of using double quotes instead of single quotes. Although due to this silly mistake at my end, I ended up upgrading Micronaut version to 1.0.1 and used @Property(name = "aws.secretkeyid") :D
– Aditya Thakur
Nov 23 at 18:06
I was going to answer it myself but your answer is correct as per the question. :)
– Aditya Thakur
Nov 23 at 18:07
add a comment |
You are using it incorrectly, you are injecting the literal value aws.secretkeyid
, not the value of a variable.
The correct syntax is:
@Value('${aws.secretkeyid}')
String keyId
Notice that you must use single quotes to avoid Groovy to attempt interpolation
The syntax you mentioned is for Java, not for Groovy. I tried it first thing as it was in [send mail in micronaut] documentation, but code does not even compile if you use above syntax.
– Aditya Thakur
Nov 23 at 11:05
1
The syntax I posted is for Groovy and does compile indeed. Notice that you must use single quotes to avoid Groovy to attempt interpolation.
– Álvaro Sánchez-Mariscal
Nov 23 at 11:10
1
Indeed you are right, I made the mistake of using double quotes instead of single quotes. Although due to this silly mistake at my end, I ended up upgrading Micronaut version to 1.0.1 and used @Property(name = "aws.secretkeyid") :D
– Aditya Thakur
Nov 23 at 18:06
I was going to answer it myself but your answer is correct as per the question. :)
– Aditya Thakur
Nov 23 at 18:07
add a comment |
You are using it incorrectly, you are injecting the literal value aws.secretkeyid
, not the value of a variable.
The correct syntax is:
@Value('${aws.secretkeyid}')
String keyId
Notice that you must use single quotes to avoid Groovy to attempt interpolation
You are using it incorrectly, you are injecting the literal value aws.secretkeyid
, not the value of a variable.
The correct syntax is:
@Value('${aws.secretkeyid}')
String keyId
Notice that you must use single quotes to avoid Groovy to attempt interpolation
edited Nov 28 at 6:20
saw303
3,42712955
3,42712955
answered Nov 23 at 10:54
Álvaro Sánchez-Mariscal
396210
396210
The syntax you mentioned is for Java, not for Groovy. I tried it first thing as it was in [send mail in micronaut] documentation, but code does not even compile if you use above syntax.
– Aditya Thakur
Nov 23 at 11:05
1
The syntax I posted is for Groovy and does compile indeed. Notice that you must use single quotes to avoid Groovy to attempt interpolation.
– Álvaro Sánchez-Mariscal
Nov 23 at 11:10
1
Indeed you are right, I made the mistake of using double quotes instead of single quotes. Although due to this silly mistake at my end, I ended up upgrading Micronaut version to 1.0.1 and used @Property(name = "aws.secretkeyid") :D
– Aditya Thakur
Nov 23 at 18:06
I was going to answer it myself but your answer is correct as per the question. :)
– Aditya Thakur
Nov 23 at 18:07
add a comment |
The syntax you mentioned is for Java, not for Groovy. I tried it first thing as it was in [send mail in micronaut] documentation, but code does not even compile if you use above syntax.
– Aditya Thakur
Nov 23 at 11:05
1
The syntax I posted is for Groovy and does compile indeed. Notice that you must use single quotes to avoid Groovy to attempt interpolation.
– Álvaro Sánchez-Mariscal
Nov 23 at 11:10
1
Indeed you are right, I made the mistake of using double quotes instead of single quotes. Although due to this silly mistake at my end, I ended up upgrading Micronaut version to 1.0.1 and used @Property(name = "aws.secretkeyid") :D
– Aditya Thakur
Nov 23 at 18:06
I was going to answer it myself but your answer is correct as per the question. :)
– Aditya Thakur
Nov 23 at 18:07
The syntax you mentioned is for Java, not for Groovy. I tried it first thing as it was in [send mail in micronaut] documentation, but code does not even compile if you use above syntax.
– Aditya Thakur
Nov 23 at 11:05
The syntax you mentioned is for Java, not for Groovy. I tried it first thing as it was in [send mail in micronaut] documentation, but code does not even compile if you use above syntax.
– Aditya Thakur
Nov 23 at 11:05
1
1
The syntax I posted is for Groovy and does compile indeed. Notice that you must use single quotes to avoid Groovy to attempt interpolation.
– Álvaro Sánchez-Mariscal
Nov 23 at 11:10
The syntax I posted is for Groovy and does compile indeed. Notice that you must use single quotes to avoid Groovy to attempt interpolation.
– Álvaro Sánchez-Mariscal
Nov 23 at 11:10
1
1
Indeed you are right, I made the mistake of using double quotes instead of single quotes. Although due to this silly mistake at my end, I ended up upgrading Micronaut version to 1.0.1 and used @Property(name = "aws.secretkeyid") :D
– Aditya Thakur
Nov 23 at 18:06
Indeed you are right, I made the mistake of using double quotes instead of single quotes. Although due to this silly mistake at my end, I ended up upgrading Micronaut version to 1.0.1 and used @Property(name = "aws.secretkeyid") :D
– Aditya Thakur
Nov 23 at 18:06
I was going to answer it myself but your answer is correct as per the question. :)
– Aditya Thakur
Nov 23 at 18:07
I was going to answer it myself but your answer is correct as per the question. :)
– Aditya Thakur
Nov 23 at 18:07
add a comment |
If anyone else stumbles upon this problem, you also have alternative to use @Property annotation in Micronaut ( starting from version 1.0.1 )
Syntax is as follows
@Property(name = "your.application.property")
String propertyName
PS : This is what was mentioned in Micronaut Documentation but was not working in my case as I was on Micronaut Version 1.0.0
add a comment |
If anyone else stumbles upon this problem, you also have alternative to use @Property annotation in Micronaut ( starting from version 1.0.1 )
Syntax is as follows
@Property(name = "your.application.property")
String propertyName
PS : This is what was mentioned in Micronaut Documentation but was not working in my case as I was on Micronaut Version 1.0.0
add a comment |
If anyone else stumbles upon this problem, you also have alternative to use @Property annotation in Micronaut ( starting from version 1.0.1 )
Syntax is as follows
@Property(name = "your.application.property")
String propertyName
PS : This is what was mentioned in Micronaut Documentation but was not working in my case as I was on Micronaut Version 1.0.0
If anyone else stumbles upon this problem, you also have alternative to use @Property annotation in Micronaut ( starting from version 1.0.1 )
Syntax is as follows
@Property(name = "your.application.property")
String propertyName
PS : This is what was mentioned in Micronaut Documentation but was not working in my case as I was on Micronaut Version 1.0.0
answered Nov 23 at 18:17
Aditya Thakur
162112
162112
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53436144%2fhow-do-i-read-application-properties-in-micronaut%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown