I want to put my page addresses in the yml file, but I have a problem with this.
path:
api.v1.0: /api/v1.0
api.v1.0:
register: ${path.api.v1.0}/register
register:
token: ${path.api.v1.0.register}/token/{token}
during the compilation it gets such a mistake
Caused by: org.yaml.snakeyaml.parser.ParserException: while parsing MappingNode
in 'reader', line 5, column 5:
register: ${path.api.v1.0}/register
^
Duplicate key: register
in 'reader', line 39, column 1:
Why does it not work?
PS: Is this a good way to place addresses in yml or properties file? Is it professional?
Whether it is good or not depends on the intended uses so I can't add much value there. But the duplication is because your objects have duplicate keys. You might want to consider an array as a data structure:
paths:
-
name: api.v1.0
path: /api/v1.0
paths:
-
name: register
path: "${path.api.v1.0}/register"
-
name: register-token
path: "${path.api.v1.0.register}/token/{token}"
Related
I've a yaml fileto be passed as an argument to the java class. But it throws below exception:
Logs
Caused by: Cannot create property=heartbeatThreshold for JavaBean=UdsConfigurationBean{jdbcDriverClassString='org.mariadb.jdbc.Driver', sparkConfigFile='spark/spark-local.conf'}
in 'reader', line 15, column 3:
jdbcDriverClassString: org.maria ...
^
Unable to find property 'heartbeatThreshold' on class: MyClass
in 'reader', line 36, column 23:
heartbeatThreshold: 60000000
^
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:292)
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:171)
at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:230)
at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:219)
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:269)
... 12 more
Caused by: org.yaml.snakeyaml.error.YAMLException: Unable to find property 'heartbeatThreshold' on class: MyClass
at org.yaml.snakeyaml.introspector.PropertyUtils.getProperty(PropertyUtils.java:159)
at org.yaml.snakeyaml.introspector.PropertyUtils.getProperty(PropertyUtils.java:148)
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.getProperty(Constructor.java:309)
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:230)
... 16 more
My Analysis:
MyClass is packaged as jar and it works for another project,so there should be problem with my yaml file.
Yaml validations has passed and seems all the variables are using camelCase.
As per my findings, PropertyUtils has 2 checks for this exception to be thrown, if property value is null(which it is not as per logs) and isWritable(I didn't get this part)
for jdbcDriverClassString, error indication is at name and for heartbeatThreshold value, its at value.
Can you please help me figure it out. I would be really grateful.
Yaml file:
kafka:
kafkaServers: ${udsKafkaEpfConfigurationBean.kafka.kafkaServers}
kafkaPrincipal: ${udsKafkaEpfConfigurationBean.kafka.kafkaPrincipal}
kafkaKeytab: ${udsKafkaEpfConfigurationBean.kafka.kafkaKeytab}
kafkaEnvironment: ${udsKafkaEpfConfigurationBean.kafka.kafkaEnvironment}
storage:
jdbcDriverClassString: ${memsql.driver}
initializationStoresGeneration: true
heartbeatThreshold: ${MyCLass.kafka.heartbeatThreshold}
For me, add Skip Missing Properties property to the yaml fixes the problem:
Yaml = new Yaml()
change to
Representer represent = new Representer()
represent.getPropertyUtils().setSkipMissingProperties(true)
Yaml yaml = new Yaml(represent)
We are trying to add in automated metrics to our Java Application, with Dropwizard metrics. So far, the config.yml file looks like this:
metrics:
reporters:
- type: log
logger: metrics
frequency: 5 minute
includes: "io.dropwizard.jetty.MutableServletContextHandler.active-requests","io.dropwizard.jetty.MutableServletContextHandler.active-dispatches","io.dropwizard.jetty.MutableServletContextHandler.active-suspended"
When running this project, we get an error stating that the yaml file is malformed:
io.dropwizard.configuration.ConfigurationParsingException: test/config.yml has an error:
* Malformed YAML at line: 24, column: 82; while parsing a block mapping
in 'reader', line 20, column 5:
- type: log
^
expected <block end>, but found FlowEntry
in 'reader', line 23, column 81:
... tContextHandler.active-requests","io.dropwizard.jetty.MutableSer ...
^
What exactly is wrong with the way the yaml is written here? My understanding is that the indentation, the spaces, and not having commas in within quotes were correct for this, and we're not able to find any other issues.
Just change line 6 to
includes: [io.dropwizard.jetty.MutableServletContextHandler.active-requests,io.dropwizard.jetty.MutableServletContextHandler.active-dispatches,io.dropwizard.jetty.MutableServletContextHandler.active-suspended]
I have a JAR which contains an application.yml. That YAM file contains an array, e.g.:
things:
- name: one
color: red
I need to adjust this array at runtime by adding an additional application.yml file in the same directory as the JAR. However, I'm not sure how to append to the array, because the follow config seems to replace the config in the built-in YAML file in the JAR:
things:
- name: red
color: blue
In the end, during runtime, I need this:
things:
- name: one
color: red
- name: two
color: blue
There looks like a similar question was asked. Doesn't sound like it's supported. Looking through docs, I've found is some older docs show it's not supported.
When a collection is specified in multiple profiles, the one with highest priority is used (and only that one):
foo:
list:
- name: my name
description: my description
- name: another name
description: another description
---
spring:
profiles: dev
foo:
list:
- name: my another name
In the example above, considering that the dev profile is active, FooProperties.list will contain one MyPojo entry (with name “my another name” and description null).
A newer 2.6.0 snapshot doc mentions the same but seems to encourage you name your keys as their own objects. You might not have access to the beans bringing them in but it might be good to structure others in this way if you can.
Consider the following configuration:
my:
map:
key1:
name: "my name 1"
description: "my description 1"
---
spring:
config:
activate:
on-profile: "dev"
my:
map:
key1:
name: "dev name 1"
key2:
name: "dev name 2"
description: "dev description 2"
If the dev profile is not active, MyProperties.map contains one entry with key key1 (with a name of my name 1 and a description of my description 1). If the dev profile is enabled, however, map contains two entries with keys key1 (with a name of dev name 1 and a description of my description 1) and key2 (with a name of dev name 2 and a description of dev description 2).
I have 2 JAR files coming from an SDK that I have to use.
Generation problem
I succeeded in generating the first .pas file, but Java2OP fails to generate the second .pas I need, with the message
Access violation at address 0042AF4A dans the 'Java2OP.exe' module. Read at address 09D00000
Would this come from a common issue? There's no other hints about what causes the problem in the SDK .jar.
I'm using Java2OP located in C:\Program Files (x86)\Embarcadero\Studio\18.0\bin\converters\java2op, but I had to first use the solutions in Delphi 10.1 Berlin - Java2OP: class or interface expected before generating the 1st file.
Compilation problem
Anyway, I tried to generate a .hpp file from the generated .pas.
I don't know much about Delphi. Does the problem come from the SDK itself, or the generation of the .pas file?
1st issue solved
Java2OP included Androidapi.JNI.Java.Util
and not Androidapi.JNI.JavaUtil. I had to import Androidapi.JNI.JavaUtil myself, though it is present in the /Program Files(x86)/Embarcadero/... folders.
2nd issue
The same 4 compilation errors happen multiple times across the .pas file on parts using the word this.
Do I have to replace every use of this with self?
Errors
E2023 The function require a type of result : Line 4
E2147 The property 'this' doesn't exist in the base class : Line 5
E2029 ',' or ':' awaited but found 'read' identificator : Line 5
E2029 ',' or ':' awaited but found number : Line 5
[JavaSignature('com/hsm/barcode/DecoderConfigValues$SymbologyFlags')]
JDecoderConfigValues_SymbologyFlags = interface(JObject)
['{BCF30FD2-B650-433C-8A4E-8B638A508487}']
function _Getthis$0: JDecoderConfigValues; cdecl;
property this$0: JDecoderConfigValues read _Getthis$0;
end;
[JavaSignature('com/hsm/barcode/ExposureValues$ExposureSettingsMinMax')]
JExposureValues_ExposureSettingsMinMax = interface(JObject)
['{A576F85F-A021-475C-9741-06D92DBC205F}']
function _Getthis$0: JExposureValues; cdecl;
property this$0: JExposureValues read _Getthis$0;
end;
I have two property files:
#environment.properties
env = production
and second file is:
#commons.properties
production.port = 123
test.port = 567
Also,I have resource file which need be filtered by environment.properties file and commons.properties file and copied.
The resource-file contains:
${${env}.port}
So,I want to filter my resource file with first file and get:
${production.port}
and then I want to filter it with second filter file and get:
123
I use maven 3.2.5 and the resource-file isn't filtered at all.
I know that there's issue related with this problem:
https://jira.codehaus.org/browse/MRESOURCES-70 But it still unresolved.
So,my question is - is there any solution to resolve this problem? (actually,I think that resource-plugin should be modified for work with nested property filtering).
And second question - does exist any way to avoid this problem by refactoring,I mean any other architecture solution. Or, what would you do if you had same problem?