質問編集履歴

1

設定ファイルを追記しました。

2018/04/01 08:45

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -99,3 +99,231 @@
99
99
  @Table(name="TechSearchList")を定義していたので、TechSearchListというテーブルを見ていると思ったのですが、クラス名のテーブルが勝手に作られるものなのでしょうか。
100
100
 
101
101
  ご存知の方がいたら教えていただきたいです。
102
+
103
+
104
+
105
+ 設定ファイルを追記します。
106
+
107
+
108
+
109
+ persistence.xml
110
+
111
+ ```persistence.xml
112
+
113
+ <?xml version="1.0" encoding="UTF-8"?>
114
+
115
+ <persistence version="2.1"
116
+
117
+ xmlns="http://xmlns.jcp.org/xml/ns/persistence"
118
+
119
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
120
+
121
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
122
+
123
+ http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
124
+
125
+
126
+
127
+ <persistence-unit name="persistenceUnit"
128
+
129
+ transaction-type="RESOURCE_LOCAL">
130
+
131
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
132
+
133
+ <properties>
134
+
135
+ <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
136
+
137
+ <property name="hibernate.hbm2ddl.auto" value="create" />
138
+
139
+ <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
140
+
141
+ <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost/××××" />
142
+
143
+ <property name="hibernate.connection.password" value="××××××" />
144
+
145
+ <property name="hibernate.connection.username" value="user1" />
146
+
147
+ </properties>
148
+
149
+ </persistence-unit>
150
+
151
+ </persistence>
152
+
153
+ ```
154
+
155
+
156
+
157
+ application-config.xml
158
+
159
+ ```ここに言語を入力
160
+
161
+ <?xml version="1.0" encoding="UTF-8"?>
162
+
163
+
164
+
165
+ <beans xmlns="http://www.springframework.org/schema/beans"
166
+
167
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
168
+
169
+ xmlns:jdbc="http://www.springframework.org/schema/jdbc"
170
+
171
+ xmlns:tx="http://www.springframework.org/schema/tx"
172
+
173
+ xmlns:jpa="http://www.springframework.org/schema/data/jpa"
174
+
175
+ xmlns:context="http://www.springframework.org/schema/context"
176
+
177
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
178
+
179
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
180
+
181
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
182
+
183
+ http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd
184
+
185
+ http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
186
+
187
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
188
+
189
+
190
+
191
+ <!-- Uncomment and add your base-package here:
192
+
193
+ <context:component-scan
194
+
195
+ base-package="org.springframework.samples.service"/> -->
196
+
197
+
198
+
199
+ <context:property-placeholder
200
+
201
+ location="classpath:spring/database.properties" />
202
+
203
+
204
+
205
+ <context:annotation-config />
206
+
207
+ <context:component-scan base-package="co.jp.TechMemo" />
208
+
209
+ <jpa:repositories base-package="co.jp.TechMemo.Repository" />
210
+
211
+
212
+
213
+
214
+
215
+ <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
216
+
217
+
218
+
219
+ <bean id="transactionManager"
220
+
221
+ class="org.springframework.orm.jpa.JpaTransactionManager">
222
+
223
+ <property name="entityManagerFactory" ref="entityManagerFactory" />
224
+
225
+ </bean>
226
+
227
+
228
+
229
+ <bean id="entityManagerFactory"
230
+
231
+ class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
232
+
233
+ <property name="jpaVendorAdapter">
234
+
235
+ <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
236
+
237
+ <property name="showSql" value="true" />
238
+
239
+ </bean>
240
+
241
+ </property>
242
+
243
+ <property name="persistenceUnitName" value="persistenceUnit" />
244
+
245
+ <property name="dataSource" ref="dataSource" />
246
+
247
+ <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
248
+
249
+ </bean>
250
+
251
+ <!-- jdbc -->
252
+
253
+ <bean class ="org.apache.commons.dbcp.BasicDataSource" id="dataSource">
254
+
255
+ <property name="driverClassName" value="${database.driverClassName}" />
256
+
257
+ <property name="url" value="${database.url}" />
258
+
259
+ <property name="username" value="${database.username}" />
260
+
261
+ <property name="password" value="${database.password}" />
262
+
263
+ </bean>
264
+
265
+
266
+
267
+ <bean class="org.springframework.jdbc.core.JdbcTemplate">
268
+
269
+ <constructor-arg ref="dataSource" />
270
+
271
+ </bean>
272
+
273
+
274
+
275
+ <jpa:repositories base-package="co.jp.springbook.TechMemo.Repository" />
276
+
277
+ </beans>
278
+
279
+ ```
280
+
281
+
282
+
283
+ mvc-config.xml
284
+
285
+ ```ここに言語を入力
286
+
287
+ <?xml version="1.0" encoding="UTF-8"?>
288
+
289
+
290
+
291
+ <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
292
+
293
+ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
294
+
295
+ xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
296
+
297
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
298
+
299
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
300
+
301
+
302
+
303
+ <!-- Uncomment and your base-package here -->
304
+
305
+ <context:component-scan base-package="co.jp.TechMemo.controller" />
306
+
307
+ <context:component-scan base-package="co.jp.TechMemo.Service.TechSearchSerive" />
308
+
309
+
310
+
311
+ <mvc:annotation-driven />
312
+
313
+
314
+
315
+ <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
316
+
317
+ <!-- Example: a logical view name of 'showMessage' is mapped to '/WEB-INF/jsp/showMessage.jsp' -->
318
+
319
+ <property name="prefix" value="/WEB-INF/view/"/>
320
+
321
+ <property name="suffix" value=".jsp"/>
322
+
323
+ </bean>
324
+
325
+
326
+
327
+ </beans>
328
+
329
+ ```