首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我可以将IntelliJ配置为在git中自动完成spring引导属性吗?

我可以将IntelliJ配置为在git中自动完成spring引导属性吗?
EN

Stack Overflow用户
提问于 2021-02-20 01:57:18
回答 2查看 807关注 0票数 3

我有一个多模块maven项目(monorepo),其中包含一个用于配置的目录(由spring服务器使用),我希望将IntelliJ配置为使用spring配置处理器自动完成属性。

元数据(additional-spring-configuration-metadata.json)是在微服务模块中正确生成的,但我不知道如何配置Intellij使其在目录中使用外部化配置自动完成。这个是可能的吗?

我尝试将普通配置目录变成maven模块,并添加spring。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-01-03 19:29:37

我找不到一条笔直的路,但这能帮到你:

https://intellij-support.jetbrains.com/hc/en-us/community/posts/360005091880-spring-cloud-config-documentation-and-completion

这种方法是使用spring初始化器制作一些虚拟应用程序,并将其放入配置回购( config repo )中。这样,intellij将启用自动完成。您必须添加所有需要自动完成的模块。

票数 2
EN

Stack Overflow用户

发布于 2022-03-28 07:42:35

我发现的“最小侵入性方法”如下:放置具有以下内容的configurationName.iml文件

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
  <component name="FacetManager">
    <facet type="Spring" name="Spring">
      <configuration />
    </facet>
  </component>
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
    <output url="file://$MODULE_DIR$/target/classes" />
    <output-test url="file://$MODULE_DIR$/target/test-classes" />
    <content url="file://$MODULE_DIR$">
      <excludeFolder url="file://$MODULE_DIR$/target" />
    </content>
    <orderEntry type="library" scope="PROVIDED" name="Maven: com.my.component:Major.Minor.Patch-SNAPSHOT" level="project" />
    ...
    <orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.6.4" level="project" />
    <orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework.boot:spring-boot-actuator-autoconfigure:2.6.4" level="project" />
    <orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.6.4" level="project" />
    ...
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
</module>

在yml文件的文件夹里。它是IntelliJ项目文件的简化版本,它应该引用项目中随

代码语言:javascript
复制
*spring-configuration-metadata.json

可以使用文件搜索来识别它们。

代码语言:javascript
复制
spring-configuration-metadata.json

在(非配置但代码)项目中,选择搜索“所有位置”。

使用“在查找工具窗口中打开”(搜索对话框的最右边角)可以方便地将文件路径复制到剪贴板进行编辑和提取。

如果依赖项发生变化,这种方法的缺点是过时的,但是由于SpringConfigurationmetadata.json不经常更新,而且任务也不是关键的,这对我来说是可以接受的。

一个“这些模块已经从Maven结构中删除”弹出弹出,不要选择从项目中删除模块,这将破坏自动建议。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66287246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档