前提・実現したいこと
質問です。
http://tech.pjin.jp/blog/2016/06/10/springframework8/
上記のサイトでspringの勉強をしており、
STSとMySQLの連携をしたいです。
発生している問題・エラーメッセージ
application-config.xmlを指示通り書き換えたところ、 Multiple annotations found at this line: - cvc-complex-type.2.4.a: Invalid content was found starting with element 'property'. One of '{"http:// www.springframework.org/schema/beans":description, "http://www.springframework.org/schema/beans":meta, "http:// www.springframework.org/schema/beans":bean, "http://www.springframework.org/schema/beans":ref, "http:// www.springframework.org/schema/beans":idref, "http://www.springframework.org/schema/beans":value, "http:// www.springframework.org/schema/beans":null, "http://www.springframework.org/schema/beans":array, "http:// www.springframework.org/schema/beans":list, "http://www.springframework.org/schema/beans":set, "http:// www.springframework.org/schema/beans":map, "http://www.springframework.org/schema/beans":props, WC[##other:"http:// www.springframework.org/schema/beans"]}' is expected. Multiple annotations found at this line: - Start tag of element <property> - cvc-complex-type.2.4.a: Invalid content was found starting with element 'property'. One of '{"http:// www.springframework.org/schema/beans":description, "http://www.springframework.org/schema/beans":meta, "http:// www.springframework.org/schema/beans":bean, "http://www.springframework.org/schema/beans":ref, "http:// www.springframework.org/schema/beans":idref, "http://www.springframework.org/schema/beans":value, "http:// www.springframework.org/schema/beans":null, "http://www.springframework.org/schema/beans":array, "http:// www.springframework.org/schema/beans":list, "http://www.springframework.org/schema/beans":set, "http:// www.springframework.org/schema/beans":map, "http://www.springframework.org/schema/beans":props, WC[##other:"http:// www.springframework.org/schema/beans"]}' is expected. Multiple annotations found at this line: - End tag of element <property> - The element type "bean" must be terminated by the matching end-tag "</ bean>". 以上の3つのエラーを吐いてしまいます。
該当のソースコード
<?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:context="http://www.springframework.org/schema/context" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- Uncomment and add your base-package here: <context:component-scan base-package="org.springframework.samples.service"> --> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource" > <property name="packagesToScan" value="jp.ssie.helloworld.model" > <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" > </property> <property name="jpaProperties"> <props> <prop key="hibernate.hbm2ddl.auto">none</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect </prop> </props> </property> </bean><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" >
<property name="url" value="${jdbc.url}" >
<property name="username" value="${jdbc.username}" >
<property name="password" value="${jdbc.password}" >
<property name="removeAbandoned" value="true" >
<property name="initialSize" value="3" >
<property name="maxActive" value="30" >
<property name="validationQuery" value="select now()" >
</bean>
<context:property-placeholder location="classpath:jdbc.properties" >
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSource" > </bean> <bean id="namedParameterJdbcTemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate"> <constructor-arg ref="dataSource" > </bean><jpa:repositories base-package="jp.ssie.helloworld.repository">
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" >
</bean>
<tx:annotation-driven >
</beans>
試したこと
終了タグなどがおかしいのかと思い、色々いじってみましたが、
application-config.xmlの書き方もよく分かっておらず、終了タグがいるものといらないものとあって
よく分かりませんでした。
補足情報(FW/ツールのバージョンなど)
macOS Sierra
STS 3.7.3.RELEASE

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/06/28 12:01
2018/09/06 04:10