如何在IntelliJ IDEA中配置Spring facet

时间:2015-09-30 08:40:22

标签: spring intellij-idea

我是Intellij 14.0的新手。我当时正在使用Netbeans,但我的同事告诉我转移到intellij,所以我做了。

我需要运行我在Intellij上运行netbeans的同一个项目。我正在研究的项目是用grails和spring制作的。当我尝试使用Intellij运行项目时,这就是我得到的。

  

弹簧配置检查   找到未映射的Spring配置文件。   请为模块配置/设置Spring facet:   .........(1档)

这是文件。

的applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="grailsApplication" class="org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBean">
        <description>Grails application factory bean</description>
        <property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
        <property name="grailsResourceLoader" ref="grailsResourceLoader" />
    </bean>

    <bean id="pluginManager" class="org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean">
        <description>A bean that manages Grails plugins</description>
        <property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
        <property name="application" ref="grailsApplication" />
    </bean>

    <bean id="grailsConfigurator" class="org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator">
        <constructor-arg>
            <ref bean="grailsApplication" />
        </constructor-arg>
        <property name="pluginManager" ref="pluginManager" />
    </bean>

    <bean id="grailsResourceLoader" class="org.codehaus.groovy.grails.commons.GrailsResourceLoaderFactoryBean" />

    <bean id="characterEncodingFilter" class="org.springframework.web.filter.CharacterEncodingFilter">
        <property name="encoding">
            <value>utf-8</value>
        </property>
    </bean>

    <bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean" />
</beans>

老实说,我不知道如何解决它。根据我的理解,它正在寻找一些模块,但我无法解决它。我甚至试过这个“添加框架支持”。但我在名单中找不到弹簧。

你可以帮我解决这个问题吗?感谢

3 个答案:

答案 0 :(得分:31)

转到文件/项目结构/模块,单击绿色加号图标,从下拉列表中选择Spring,然后在下一个对话框中选择您的模块。

然后单击右窗格中的绿色加号,单击加号并选择Spring配置文件和类,然后单击“确定”。

另请参阅IntelliJ Help的Spring Facet。

答案 1 :(得分:0)

IntelliJ Ultimate 2018-手动方式:

  1. 菜单文件->项目结构
  2. 右键单击您的模块,然后选择“添加...”-> Spring
  3. 如果未将spring列为依赖项,则可以单击“修复”
  4. 单击顶部的+图标添加您的spring配置.xml文件

enter image description here

自动方式:

  1. 单击弹出通知的正文
  2. 点击“创建默认值”选项

enter image description here

答案 2 :(得分:0)

今天刚刚遇到了这个问题-我的构建昨天晚上工作了,今天早上它停止了工作-所以我想我可以使用 IntelliJIDE CE 2019.1 发布我的解决方案。 / p>

错误消息(以帮助人们找到此答案)

package org.springframework.transaction.annotation does not exist
package org.springframework.boot does not exist
Unknown facet type: 'Spring'
Unknown facet type: 'web'

enter image description here


解决方案

步骤0 : 更新IntelliJ

Menu: IntelliJIDE > Check for Updates (Mac OSX) 

第1步: 清除Maven存储库并重新下载依赖项,以确保源没有损坏。这将需要5分钟以上的时间。

$ cd [project_directory]
$ mvn dependency:purge-local-repository

第2步: 执行全新安装。

$ mvn clean install

第3步: 更新IntelliJIDE的存储库索引:

  1. 打开IntelliJ设置/首选项
  2. 构建,执行,部署>构建工具> Maven>存储库
  3. 一个一个地选择存储库(通过单击表行),然后单击更新按钮。具体来说,请针对 https://repo.mave.apache.org/maven2 执行此操作。下载大小为±700mb,因此需要一段时间。 (10分钟以上) enter image description here

相关问题