10

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

  1. Errors in idea for beans tag.
    enter image description here

But it is working good.

How to avoid red errors ?

P.S.

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>
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

3 Answers3

5

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

Sunil Kumar
  • 5,477
  • 4
  • 31
  • 38
  • Any idea where this `p` namespace if defined in Spring?? I spent a considerable amount of time, trying to find the XSD for `http://www.springframework.org/schema/p` namespace, and then stumbled on this comment.. Atleast, now I will stop looking for an XSD file for `p` – ARK Jul 04 '19 at 23:55
1

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.

Adeeb Cheulkar
  • 1,128
  • 2
  • 10
  • 22
0

You're registering "p" as a namespace using a schema that doesn't exist. If you don't have any tags like <p: ></p: >, then your config will still work at runtime. However, your IDE checks to make sure all namespace definitions are correct (even if unused).

The easiest way to fix it is to remove the offending namespace definition. If you are using that namespace, find the correct location for the schema and place it there.

Laplie Anderson
  • 6,345
  • 4
  • 33
  • 37
  • I have tags like **** and spring beans looks like correct location – gstackoverflow Jun 04 '15 at 06:42
  • what namespace are those referring too? If you notice, all of the other urls (http://www.springframework.org/schema/tx, http://www.springframework.org/schema/beans, etc) are working and go to the XSD when put into a browser. http://www.springframework.org/schema/p doesn't. – Laplie Anderson Jun 04 '15 at 13:56
  • can you write exact xml content which I should write ? – gstackoverflow Jun 05 '15 at 13:54