Java Intellij IDEA没有';无法从属性文件中检测属性

Java Intellij IDEA没有';无法从属性文件中检测属性,java,jakarta-ee,intellij-idea,Java,Jakarta Ee,Intellij Idea,我遇到了一个糟糕的情况,但解决不了。我用Intellij IDEA编写了SpringMVC+Hibernate应用程序。我想把我所有的jdbc属性(连接url、用户名等)放在jdbc.properties中,但IDEA在这个文件中无法检测到它们。这是我的WEB-INF/dispatcher-servlet.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.or

我遇到了一个糟糕的情况,但解决不了。我用Intellij IDEA编写了SpringMVC+Hibernate应用程序。我想把我所有的jdbc属性(连接url、用户名等)放在jdbc.properties中,但IDEA在这个文件中无法检测到它们。这是我的WEB-INF/dispatcher-servlet.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"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util"
       xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <mvc:annotation-driven/>
    <context:component-scan base-package="com.controllers"/>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

    <bean id="fileCreator" class="com.utilites.FileCreator"/>

    <tx:annotation-driven transaction-manager="transactionManager"/>

    <bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"
          p:driverClassName="${jdbc.driverClassName}"
          p:url="${jdbc.url}"
          p:username="${jdbc.username}"
          p:password="${jdbc.password}"/>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation">
            <value>classpath:hibernate.cfg.xml</value>
        </property>
        <!--<property name="configurationClass">-->
        <!--<value>org.hibernate.cfg.AnnotationConfiguration</value>-->
        <!--</property>-->
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.connection.charSet">UTF-8</prop>
            </props>
        </property>
    </bean>

    <bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
</beans>
pom.xml中的mysql依赖关系:

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.32</version>
        </dependency>

我的应用程序或esle中的某个地方出了什么问题?

.properties
文件保存在
resources
下,并将其添加到
bean
定义之上:

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations" value="classpath:jdbc.properties"/>
</bean>


我确信这不是Intellij的想法问题。您是从文件还是在pom.xml中将驱动程序导入到项目中的?如果是,请显示相关代码/文件。您是否在bean配置文件中声明了PropertyPlaceHolderConfigure
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [${jdbc.driverClassName}];
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations" value="classpath:jdbc.properties"/>
</bean>