gst*_*low 7 java validation spring xml-namespaces xml-configuration
我有以下spring xml配置头:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:task="http://www.springframework.org/schema/task"
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/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
<tx:annotation-driven transaction-manager="transactionManager"/>
....
Run Code Online (Sandbox Code Playgroud)
当我在想法中打开文件时,我看到红色错误:1.xmlns:p="http://www.springframework.org/schema/p -
URI未注册

但它运作良好.
如何避免红色错误?
我的xml配置中有以下片段:
<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="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.connection.charSet">UTF-8</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hbm2ddl.auto">validate</prop>
</props>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
一种特殊的命名空间(p命名空间)没有在XSD文件中定义,仅存在于Spring本身的核心中。p-namespace 不需要模式定义,它是配置属性的另一种方法,与您目前看到的方式不同。
由于p: "namespaces" 没有关联的 XSD 方案,Intelijj 无法验证此命名空间。
一种解决方案是在 IDEA 中关闭验证,但您找不到其他问题。
Intelijj IDEA 似乎没有为这个问题提供任何解决方案。 https://youtrack.jetbrains.com/issue/IDEA-101723
您正在使用不存在的架构将“p”注册为命名空间。如果您没有任何类似 的标签<p: ></p: >,那么您的配置仍将在运行时起作用。但是,您的 IDE 会进行检查以确保所有命名空间定义都是正确的(即使未使用)。
修复它的最简单方法是删除有问题的命名空间定义。如果您正在使用该命名空间,请找到该架构的正确位置并将其放置在那里。
| 归档时间: |
|
| 查看次数: |
5805 次 |
| 最近记录: |