I have the following spring xml configuration header:
<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"/>
....
When I open file in idea I see red errors:
1.xmlns:p="http://www.springframework.org/schema/p
-
URI is not registered
But it is working good.
How to avoid red errors ?
I have the following fragment in my xml configuration:
<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>
One special namespace(p namespace) is not defined in an XSD file, and only exists in the core of Spring itself. p-namespace doesn't need a schema definition and is an alternative way of configuring your properties differently than the way you have seen so far.
Since p: "namespaces" do not have an associated XSD scheme, Intelijj is failing to validate this namespace.
One Solution is to trun off validation in IDEA, but you cant find other issues.
It seems Intelijj IDEA does not provided any solution for this issue. https://youtrack.jetbrains.com/issue/IDEA-101723
If you remove this line of code xmlns:p="http://www.springframework.org/schema/p" from the xml then errors will be cleaned. Because there is no such xsd available in spring. Event if you want to use such xsd then you may try following code:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
p:dataSource-ref="dataSource"
p:mappingResources-ref="mappingResourcesList"
p:hibernateProperties-ref="hibernatePropertiesProps" />
Basically, they are defined to map to the same XML namespaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With