IT

일치하는 와일드카드가 엄격하지만 'tx:notation-driven' 요소에 대한 선언을 찾을 수 없습니다.

itgroup 2023. 8. 26. 10:42
반응형

일치하는 와일드카드가 엄격하지만 'tx:notation-driven' 요소에 대한 선언을 찾을 수 없습니다.

JSF+Spring+hibernate를 구성하려고 하고 테스트를 실행하려고 하는데 application-context.xml 파일에서 이 "tx:annotation-driven"을 사용하면 다음 오류가 발생합니다.

일치하는 와일드카드가 엄격하지만 'tx:notation-driven' 요소에 대한 선언을 찾을 수 없습니다.

다음은 내 application-context.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:aop="http://www.springframework.org/schema/aop"
       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-2.5.xsd
          http://www.springframework.org/schema/aop 
          http://www.springframework.org/schema/aop/spring-aop-2.5.6.xsd
          http://www.springframework.org/schema/context 
          http://www.springframework.org/schema/context/spring-context-2.5.6.xsd
          http://www.springframework.org/schema/tx 
          http://www.springframework.org/schema/tx/spring-tx-2.5.6.xsd
" xmlns:tool="http://www.springframework.org/schema/tool">
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
        <property name="url" value="jdbc:oracle:thin:@192.168.56.101:1521:Gpsi"/>
        <property name="username" value="omar"/>
        <property name="password" value="omar"/>
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
       <property name="dataSource" ref="dataSource"/>
       <property name="annotatedClasses">
            <list>
                <value>om.mycompany.model.Course</value>
                <value>om.mycompany.model.Student</value>
                <value>om.mycompany.model.Teacher</value>
            </list>
       </property>
       <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
            </props>
       </property>

    </bean>
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
       <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <tx:annotation-driven transaction.manager="transactionManager"/>

    <context:annotation-config/>
    <context:component-scan base.package="com.mmycompany"/>
</beans>

그리고 여기 제 코스서비스 임플테스트가 있습니다.아직 테스트를 구현하지 못했습니다.

public class CourseServiceImplTest {

    private static ClassPathXmlApplicationContext context;
    private static CourseService courseService;
    public CourseServiceImplTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
        context=new ClassPathXmlApplicationContext("application-context.xml");
        courseService=(CourseService) context.getBean("courseService");
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
        context.close();
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of getAllCourses method, of class CourseServiceImpl.
     */
    @Test
    public void testGetAllCourses() {
        System.out.println("getAllCourses");
        CourseServiceImpl instance = new CourseServiceImpl();
        List expResult = null;
        List result = instance.getAllCourses();
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }

    /**
     * Test of getCourse method, of class CourseServiceImpl.
     */
    @Test
    public void testGetCourse() {
        System.out.println("getCourse");
        Integer id = null;
        CourseServiceImpl instance = new CourseServiceImpl();
        Course expResult = null;
        Course result = instance.getCourse(id);
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }

다음은 CourseServiceImple입니다.

@Service("courseService")
@Transactional
public class CourseServiceImpl implements CourseService{

    @Autowired
    private SessionFactory sessionFactory;
    @Override
    public List<Course> getAllCourses() {
        return sessionFactory.getCurrentSession().createQuery("from Course").list();    
    }

    @Override
    public Course getCourse(Integer id) {
        return (Course) sessionFactory.getCurrentSession().get(Course.class, id);
    }

    @Override
    public void save(Course course) {
       sessionFactory.getCurrentSession().saveOrUpdate(course);
    }

}

appcontext.xml에 몇 가지 오류가 있습니다.

  • *-2.5.xsd 사용

    xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
      http://www.springframework.org/schema/aop 
      http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
      http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context-2.5.xsd
      http://www.springframework.org/schema/tx 
      http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
    
  • 오타tx:annotation-driven그리고.context:component-scan- 대신 (.)

    <tx:annotation-driven transaction-manager="transactionManager" />
    <context:component-scan base-package="com.mmycompany" />
    

이것은 다른 사람들을 위한 것입니다 (저와 같은) :)스프링 tx jar/maven 종속성을 추가하는 것을 잊지 마십시오.또한 appctx의 올바른 구성은 다음과 같습니다.

xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"

다른 사용자가 가지고 있을 수 있는 잘못된 구성으로 인해

xmlns:tx="http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"

예: 추가 "/spring-slot-3.1.xsd"

xsi:schemaLocation="http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"

즉, xmlns(이름 공간)에 있는 것은 schemaLocation(이름 공간 대 스키마)에 적절한 매핑이 있어야 합니다.

네임스페이스는 다음과 같습니다. http://www.springframework.org/schema/tx

스키마 네임스페이스 문서: http://www.springframework.org/schema/tx/spring-tx-3.1.xsd

나중에 네임스페이스의 이 스키마가 jar에 매핑되어 org.springframework.transaction.config에 있는 실제 xsd의 경로를 찾습니다.

저에게 효과가 있었던 것은 xsi:schemaLocation 태그에서 네임스페이스가 정의된 순서였습니다. : [버전이 모두 좋았고 이미 transaction-manager였기 때문에]

오류:

 http://www.springframework.org/schema/mvc
 http://www.springframework.org/schema/tx
 http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
 http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"

해결 방법:

http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"

저는 우데미에게 배우고 있습니다.저는 선생님이 시키는 모든 단계를 따랐습니다.개발 환경을 설정하는 동안 봄에 mvc crud 섹션에서 다음과 같은 오류가 발생했습니다.

<mvc:annotation-driven/> and <tx:annotation-driven transaction-manager="myTransactionManager" />

그러면 제가 방금 교체했습니다.

    http://www.springframework.org/schema/mvc/spring-mvc.xsd 

와 함께

    http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd

그리고.

    http://www.springframework.org/schema/tx/spring-tx.xsd

와 함께

    http://www.springframework.org/schema/tx/spring-tx-4.2.xsd

실제로 저는 이 두 사이트 http://www.springframework.org/schema/mvc/ 와 http://www.springframework.org/schema/tx/ 을 방문했고, 방금 스프링-mvc와 스프링-mvc의 최신 버전, 즉 스프링-mvc-4.2.xsd와 스프링-mvc-4.2.xsd를 추가했습니다.

그래서, 저는 이것을 시도하는 것을 제안합니다.이게 도움이 되길 바랍니다.감사해요.

tx 앞에 슬래시(/) 한 개가 추가되고 *.xml 파일이 8시간 동안 저를 괴롭혔습니다!!

내 실수:

http://www.springframework.org/schema/tx/ http://www.springframework.org/schema/tx/spring-tx-4.3.xsd

수정:

http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd

실제로 한 글자 이상이 프로그래머들을 몇 시간 동안 바쁘게 할 수 있습니다!

저의 경우 이는 실제로 AWS에서 호스팅되는 서버가 외부 네트워크에 대한 IP가 부족하기 때문에 발생한 증상입니다.springframework.org 에서 네임스페이스를 다운로드하려고 시도하지만 연결에 실패합니다.

FWIW 저도 같은 문제가 있었습니다.xsi:schemaLocation 항목이 잘못되었기 때문에 공식 문서로 가서 해당 항목을 내 문서에 붙여 넣었습니다.

http://docs.spring.io/spring/docs/current/spring-framework-reference/html/transaction.html 섹션 16.5.6

몇 개를 더 추가해야 했지만 괜찮았습니다.다음은 이것이 문제를 해결한 이유를 찾는 것입니다.

Spring 버전과 xsd 버전이 모두 동일한지 확인합니다.저의 경우 Spring 4.1.1을 사용하므로 모든 xsd는 버전 *-4.1.xsd여야 합니다.

Any one can help for me!!!!!!!!!
<?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:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:jee="http://www.springframework.org/schema/jee"
        xmlns:lang="http://www.springframework.org/schema/lang"
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/aop/ http://www.springframework.org/schema/aop/spring-aop.xsd
            http://www.springframework.org/schema/context/ http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/jee/ http://www.springframework.org/schema/jee/spring-jee.xsd
            http://www.springframework.org/schema/lang/ http://www.springframework.org/schema/lang/spring-lang.xsd
            http://www.springframework.org/schema/tx/ http://www.springframework.org/schema/tx/spring-tx.xsd
            http://www.springframework.org/schema/util/ http://www.springframework.org/schema/util/spring-util.xsd">
        <context:annotation-config />(ERROR OCCUR)
        <context:component-scan base-package="hiberrSpring" /> (ERROR OCCUR)
        <bean id="jspViewResolver"
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass"
                value="org.springframework.web.servlet.view.JstlView"></property>
            <property name="prefix" value="/WEB-INF/"></property>
            <property name="suffix" value=".jsp"></property>
        </bean>
        <bean id="messageSource"
            class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basename" value="classpath:messages"></property>
            <property name="defaultEncoding" value="UTF-8"></property>
        </bean>
        <bean id="propertyConfigurer"
            class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
            p:location="/WEB-INF/jdbc.properties"></bean>
        <bean id="dataSource"
            class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
            p:driverClassName="${com.mysql.jdbc.Driver}"
            p:url="${jdbc:mysql://localhost/}" p:username="${root}"
            p:password="${rajini}"></bean>
        <bean id="sessionFactory"
            class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="dataSource" ref="dataSource"></property>
            <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.dialect">${org.hibernate.dialect.MySQLDialect}</prop>
                    <prop key="hibernate.show_sql">true</prop>
                </props>
            </property>
        </bean>
        <bean id="employeeDAO" class="hiberrSpring.EmployeeDaoImpl"></bean>
        <bean id="employeeManager" class="hiberrSpring.EmployeeManagerImpl"></bean>
        <tx:annotation-driven /> (ERROR OCCUR)
        <bean id="transactionManager"
            class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory" ref="sessionFactory"></property>
        </bean>
    </beans>

언급URL : https://stackoverflow.com/questions/6058037/the-matching-wildcard-is-strict-but-no-declaration-can-be-found-for-element-tx

반응형