我有一个let json = [
{
"metadata": {
"id": "vvvvvvvvvvvvv",
"url": "cccccccccccccc",
"created_at": "2019-09-06T08:40:41Z",
"updated_at": "2019-09-06T13:25:46Z"
},
"entity": {
"name": "app1",
"b_enabled": false,
"d_url": "xxxxxs"
}
},
{
"metadata": {
"id": "vvvvvvvvvvccc",
"url": "cccccccccccccc",
"created_at": "2019-09-06T08:40:41Z",
"updated_at": "2019-09-06T13:25:46Z"
},
"entity": {
"name": "app2",
"b_enabled": false,
"d_url": "xxxxxs"
}
},
{
"metadata": {
"id": "vvvvvvvvvvddd",
"url": "cccccccccccccc",
"created_at": "2019-09-06T08:40:41Z",
"updated_at": "2019-09-06T13:25:46Z"
},
"entity": {
"name": "app3",
"b_enabled": false,
"d_url": "xxxxxs"
}
},
{
"metadata": {
"id": "vvvvvvvvvveee",
"url": "cccccccccccccc",
"created_at": "2019-09-06T08:40:41Z",
"updated_at": "2019-09-06T13:25:46Z"
},
"entity": {
"name": "app4",
"b_enabled": false,
"d_url": "xxxxxs"
}
},
{
"metadata": {
"id": "vvvvvvvvvvfff",
"url": "cccccccccccccc",
"created_at": "2019-09-06T08:40:41Z",
"updated_at": "2019-09-06T13:25:46Z"
},
"entity": {
"name": "app5",
"b_enabled": false,
"d_url": "xxxxxs"
}
}
]
let output = {};
// we parse each element of the json array
for(let i = 0; i < json.length; i ++ ) {
// we get the current element.
let currentElement = json[i];
// here, we are using the name of the entity as the key and the id of the metadata as the value
output[currentElement.entity.name] = currentElement.metadata.id;
}
console.log(output);
(Spring Boot application
),该用户使用的是jar jar main-app
,并提到它是应用程序client-app.jar
的依赖项。
现在,我想使用main-app
从@Autowire
注入bean。为此,我必须在我的client-app
应用程序上添加@ComponentScan
。
但是有一种方法可以通过更改main-app
上的代码来使main-app
上的任何内容都不需要。
答案 0 :(得分:0)
是的,您可以按照sub-package
来创建main-app
,假设main-app
具有包com.example.main-app
的以下根,然后在您的client-app
上,创建类似com.example.main-app.client-app
之类的内容,然后主应用程序将扫描其基本程序包,并且外观也将为client-app
。