में बाध्य नहीं है मैं वसंत के साथ एक परीक्षण परियोजना में एक जेएनडीआई डीबी कनेक्शन को परिभाषित करने की कोशिश कर रहा हूं। मैंने प्रोजेक्ट को स्प्रिंग रू के साथ बूटस्ट्रैप किया है और इस प्रकार मैवेनाइज्ड है।NameNotFoundException: नाम jdbc इस संदर्भ
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
...
<jee:jndi-lookup id="dataSource" jndi-name="/jdbc/cpool" resource-ref="true"/>
...
मैं निम्नलिखित सामग्री के साथ src/main/resources/META-INF/context.xml
बना लिया है: यहाँ मैं निम्नलिखित (रू द्वारा बनाई गई) संदर्भ के लिए रू लिपि (रू 1.2.1)
project --topLevelPackage org.obliquid.cpool
jpa setup --database MYSQL --provider HIBERNATE --jndiDataSource /jdbc/cpool
web mvc setup
entity jpa --class org.obliquid.cpool.entity.Person
field string --fieldName name
web mvc scaffold --class ~.entity.Person
web mvc all --package ~.web
src/main/resources/META-INF/spring/applicationContext.xml
में है:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/myapp" docBase="cpool" reloadable="true" debug="1">
<Resource name = "jdbc/cpool"
auth = "Container"
type = "javax.sql.DataSource"
username = "dbusername"
password = "dbpassword"
driverClassName = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://localhost:3306/dbname?DateTimeBehavior=convertToNull&characterEncoding=UTF-8"
maxActive = "100"
maxIdle = "4"
maxWait = "20000"
removeAbandoned = "true"
removeAbandonedTimeout="600"
logAbandoned="true"/>
</Context>
हालांकि
, जब मैं बिलाव 7.0 में अनुप्रयोग चलाने के लिए प्रयास करते हैं, मैं निम्नलिखित त्रुटि मिलती है:
ERROR org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
डेटास्रोत को सही ढंग से परिभाषित करने के लिए मुझे क्या करना चाहिए?
आह आह! गलत 'मेटा-आईएनएफ 'फ़ोल्डर! इसलिए मैंने 'src/main/webapp/मेटा-आईएनएफ' में 'context.xml' रखा है, और यह युद्ध फ़ाइल के '/ मेटा-आईएनएफ' फ़ोल्डर में पैक किया जाता है और सबकुछ काम करता है, आपको बहुत धन्यवाद! – stivlo
क्या यह काम करता है अगर युद्ध जेटी पर तैनात किया जाना है? – Sikorski
@ सिकोरस्की: नहीं। context.xml एक टोमकैट मालिकाना फ़ाइल है। –