我要创建与数据库的连接在Spring MVC中插入特定的值,但有以下错误在我的servlet-context.xml中,同时创建连接:Spring MVC的数据库连接
Multiple annotations found at this line: - Cannot locate BeanDefinitionParser for element [bean] - cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'bean'. - Configuration problem: Cannot locate BeanDefinitionParser for element [bean] Offending resource: file [E:/General Workspace/Spring Workspace/Record_mvc/ src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml]
我宣布豆与id="dataSource"
但它似乎不工作。你能帮助我理解为什么它找不到声明元素'bean'
什么意思
“匹配通配符是严格的”
这里是调度员的代码。提前致谢。
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
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">
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving
up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources
in the /WEB-INF/views directory -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="com.lead.mvc" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:8080/leadmanager" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>
<!-- <bean id="jdbcTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean> -->
</beans:beans>
请提供更多代码。 “dataSource”可能存在问题 –
bean id = dataSource行有错误。 – Rohit
什么类型的错误? –