鞍山市城市建设网站,长沙官网seo技术厂家,广告最多的网站,别样网站建设参考了几位同行的Blogs和StackOverflow上的许多问答#xff0c;搭建了此后端项目#xff0c;替换原来的node.js后端#xff0c;和前一篇中搭建的Vue Web App项目配合使用#xff0c;后端准备只提供服务#xff0c;不包含后端装配的页面#xff0c;打算只使用MongoDb和Red…参考了几位同行的Blogs和StackOverflow上的许多问答搭建了此后端项目替换原来的node.js后端和前一篇中搭建的Vue Web App项目配合使用后端准备只提供服务不包含后端装配的页面打算只使用MongoDb和Redis所以JPA部分注释掉了可打开使用核心文件如下供需要的人参考。 pom.xml 1 ?xml version1.0 encodingUTF-8?2 project xmlnshttp://maven.apache.org/POM/4.0.03 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance4 xsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd5 modelVersion4.0.0/modelVersion6 7 groupIdJavaWeb/groupId8 artifactIdJavaWeb/artifactId9 version1.0/version10 build11 plugins12 plugin13 groupIdorg.apache.maven.plugins/groupId14 artifactIdmaven-compiler-plugin/artifactId15 configuration16 source1.8/source17 target1.8/target18 /configuration19 /plugin20 /plugins21 /build22 23 properties24 org.springframework.version5.0.5.RELEASE/org.springframework.version25 /properties26 27 dependencies28 !-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --29 dependency30 groupIdorg.apache.commons/groupId31 artifactIdcommons-lang3/artifactId32 version3.7/version33 /dependency34 35 !-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 --36 dependency37 groupIdorg.apache.commons/groupId38 artifactIdcommons-collections4/artifactId39 version4.1/version40 /dependency41 42 !-- https://mvnrepository.com/artifact/org.apache.commons/commons-compress --43 dependency44 groupIdorg.apache.commons/groupId45 artifactIdcommons-compress/artifactId46 version1.16.1/version47 /dependency48 49 !-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 --50 dependency51 groupIdorg.apache.commons/groupId52 artifactIdcommons-math3/artifactId53 version3.6.1/version54 /dependency55 56 !-- https://mvnrepository.com/artifact/org.apache.commons/commons-io --57 dependency58 groupIdorg.apache.commons/groupId59 artifactIdcommons-io/artifactId60 version1.3.2/version61 /dependency62 63 !-- https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 --64 dependency65 groupIdorg.apache.commons/groupId66 artifactIdcommons-pool2/artifactId67 version2.5.0/version68 /dependency69 70 !-- https://mvnrepository.com/artifact/org.apache.commons/commons-text --71 dependency72 groupIdorg.apache.commons/groupId73 artifactIdcommons-text/artifactId74 version1.3/version75 /dependency76 77 !-- https://mvnrepository.com/artifact/org.apache.commons/commons-configuration2 --78 dependency79 groupIdorg.apache.commons/groupId80 artifactIdcommons-configuration2/artifactId81 version2.2/version82 /dependency83 84 !-- https://mvnrepository.com/artifact/org.apache.commons/commons-proxy --85 dependency86 groupIdorg.apache.commons/groupId87 artifactIdcommons-proxy/artifactId88 version1.0/version89 /dependency90 91 !-- https://mvnrepository.com/artifact/commons-cli/commons-cli --92 dependency93 groupIdcommons-cli/groupId94 artifactIdcommons-cli/artifactId95 version1.4/version96 /dependency97 98 99 !-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core --
100 dependency
101 groupIdcom.fasterxml.jackson.core/groupId
102 artifactIdjackson-core/artifactId
103 version2.9.5/version
104 /dependency
105
106 !-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind --
107 dependency
108 groupIdcom.fasterxml.jackson.core/groupId
109 artifactIdjackson-databind/artifactId
110 version2.9.5/version
111 /dependency
112
113 !-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations --
114 dependency
115 groupIdcom.fasterxml.jackson.core/groupId
116 artifactIdjackson-annotations/artifactId
117 version2.9.5/version
118 /dependency
119
120 !-- https://mvnrepository.com/artifact/com.fasterxml.uuid/java-uuid-generator --
121 dependency
122 groupIdcom.fasterxml.uuid/groupId
123 artifactIdjava-uuid-generator/artifactId
124 version3.1.5/version
125 /dependency
126
127 !-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api --
128 dependency
129 groupIdorg.slf4j/groupId
130 artifactIdslf4j-api/artifactId
131 version1.7.25/version
132 /dependency
133
134 !-- https://mvnrepository.com/artifact/org.slf4j/jcl-over-slf4j --
135 dependency
136 groupIdorg.slf4j/groupId
137 artifactIdjcl-over-slf4j/artifactId
138 version1.7.25/version
139 /dependency
140
141 !-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core --
142 dependency
143 groupIdorg.apache.logging.log4j/groupId
144 artifactIdlog4j-core/artifactId
145 version2.11.0/version
146 /dependency
147
148 !-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api --
149 dependency
150 groupIdorg.apache.logging.log4j/groupId
151 artifactIdlog4j-api/artifactId
152 version2.11.0/version
153 /dependency
154
155 !-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl --
156 dependency
157 groupIdorg.apache.logging.log4j/groupId
158 artifactIdlog4j-slf4j-impl/artifactId
159 version2.11.0/version
160 /dependency
161
162 !-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-web --
163 dependency
164 groupIdorg.apache.logging.log4j/groupId
165 artifactIdlog4j-web/artifactId
166 version2.11.0/version
167 /dependency
168
169 !-- https://mvnrepository.com/artifact/org.projectlombok/lombok --
170 dependency
171 groupIdorg.projectlombok/groupId
172 artifactIdlombok/artifactId
173 version1.16.20/version
174 scopeprovided/scope
175 /dependency
176
177 !-- https://mvnrepository.com/artifact/junit/junit --
178 dependency
179 groupIdjunit/groupId
180 artifactIdjunit/artifactId
181 version4.12/version
182 scopetest/scope
183 /dependency
184
185
186 !-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --
187 dependency
188 groupIdjavax.servlet/groupId
189 artifactIdjavax.servlet-api/artifactId
190 version4.0.0/version
191 scopeprovided/scope
192 /dependency
193
194 !-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api --
195 dependency
196 groupIdjavax.servlet.jsp/groupId
197 artifactIdjavax.servlet.jsp-api/artifactId
198 version2.3.1/version
199 scopeprovided/scope
200 /dependency
201
202 !-- https://mvnrepository.com/artifact/javax.servlet/jstl --
203 dependency
204 groupIdjavax.servlet/groupId
205 artifactIdjstl/artifactId
206 version1.2/version
207 /dependency
208
209 !-- https://mvnrepository.com/artifact/org.springframework/spring-core --
210 dependency
211 groupIdorg.springframework/groupId
212 artifactIdspring-core/artifactId
213 version${org.springframework.version}/version
214 /dependency
215
216 !-- https://mvnrepository.com/artifact/org.springframework/spring-beans --
217 dependency
218 groupIdorg.springframework/groupId
219 artifactIdspring-beans/artifactId
220 version${org.springframework.version}/version
221 /dependency
222
223 !-- https://mvnrepository.com/artifact/org.springframework/spring-tx --
224 dependency
225 groupIdorg.springframework/groupId
226 artifactIdspring-tx/artifactId
227 version${org.springframework.version}/version
228 /dependency
229
230 !-- https://mvnrepository.com/artifact/org.springframework/spring-context --
231 dependency
232 groupIdorg.springframework/groupId
233 artifactIdspring-context/artifactId
234 version${org.springframework.version}/version
235 /dependency
236
237 !-- https://mvnrepository.com/artifact/org.springframework/spring-context-support --
238 dependency
239 groupIdorg.springframework/groupId
240 artifactIdspring-context-support/artifactId
241 version${org.springframework.version}/version
242 /dependency
243
244 !-- https://mvnrepository.com/artifact/org.springframework/spring-aop --
245 dependency
246 groupIdorg.springframework/groupId
247 artifactIdspring-aop/artifactId
248 version${org.springframework.version}/version
249 /dependency
250
251 !-- https://mvnrepository.com/artifact/org.springframework/spring-aspects --
252 dependency
253 groupIdorg.springframework/groupId
254 artifactIdspring-aspects/artifactId
255 version${org.springframework.version}/version
256 /dependency
257
258 !-- https://mvnrepository.com/artifact/org.springframework/spring-web --
259 dependency
260 groupIdorg.springframework/groupId
261 artifactIdspring-web/artifactId
262 version${org.springframework.version}/version
263 /dependency
264
265 !-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc --
266 dependency
267 groupIdorg.springframework/groupId
268 artifactIdspring-webmvc/artifactId
269 version${org.springframework.version}/version
270 /dependency
271
272 !-- https://mvnrepository.com/artifact/org.springframework/spring-test --
273 dependency
274 groupIdorg.springframework/groupId
275 artifactIdspring-test/artifactId
276 version${org.springframework.version}/version
277 scopetest/scope
278 /dependency
279
280 !-- https://mvnrepository.com/artifact/org.springframework.session/spring-session-core --
281 dependency
282 groupIdorg.springframework.session/groupId
283 artifactIdspring-session-core/artifactId
284 version2.0.2.RELEASE/version
285 /dependency
286
287 !-- https://mvnrepository.com/artifact/org.springframework.session/spring-session-data-redis --
288 dependency
289 groupIdorg.springframework.session/groupId
290 artifactIdspring-session-data-redis/artifactId
291 version2.0.2.RELEASE/version
292 /dependency
293
294
295 !-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa --
296 dependency
297 groupIdorg.springframework.data/groupId
298 artifactIdspring-data-jpa/artifactId
299 version2.0.6.RELEASE/version
300 /dependency
301
302 !-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core --
303 dependency
304 groupIdorg.hibernate/groupId
305 artifactIdhibernate-core/artifactId
306 version5.2.16.Final/version
307 /dependency
308
309 !-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager --
310 dependency
311 groupIdorg.hibernate/groupId
312 artifactIdhibernate-entitymanager/artifactId
313 version5.2.16.Final/version
314 /dependency
315
316 !-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator --
317 dependency
318 groupIdorg.hibernate/groupId
319 artifactIdhibernate-validator/artifactId
320 version6.0.9.Final/version
321 /dependency
322
323 !-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --
324 dependency
325 groupIdmysql/groupId
326 artifactIdmysql-connector-java/artifactId
327 version5.1.6/version
328 /dependency
329
330 !-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-mongodb --
331 dependency
332 groupIdorg.springframework.data/groupId
333 artifactIdspring-data-mongodb/artifactId
334 version2.0.6.RELEASE/version
335 /dependency
336
337 !-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver --
338 dependency
339 groupIdorg.mongodb/groupId
340 artifactIdmongo-java-driver/artifactId
341 version3.6.3/version
342 /dependency
343
344 !-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-mongodb --
345 dependency
346 groupIdorg.springframework.data/groupId
347 artifactIdspring-data-redis/artifactId
348 version2.0.6.RELEASE/version
349 /dependency
350
351 !-- https://mvnrepository.com/artifact/redis.clients/jedis --
352 dependency
353 groupIdredis.clients/groupId
354 artifactIdjedis/artifactId
355 version2.9.0/version
356 /dependency
357
358
359 !-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --
360 dependency
361 groupIdorg.apache.httpcomponents/groupId
362 artifactIdhttpclient/artifactId
363 version4.5.5/version
364 /dependency
365
366 !-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore --
367 dependency
368 groupIdorg.apache.httpcomponents/groupId
369 artifactIdhttpcore/artifactId
370 version4.4.9/version
371 /dependency
372
373 !-- https://mvnrepository.com/artifact/net.sf.ehcache/ehcache --
374 dependency
375 groupIdnet.sf.ehcache/groupId
376 artifactIdehcache/artifactId
377 version2.10.5/version
378 /dependency
379
380 !-- https://mvnrepository.com/artifact/com.corundumstudio.socketio/netty-socketio --
381 dependency
382 groupIdcom.corundumstudio.socketio/groupId
383 artifactIdnetty-socketio/artifactId
384 version1.7.15/version
385 /dependency
386
387 !-- https://mvnrepository.com/artifact/org.bytedeco.javacpp-presets/ffmpeg --
388 dependency
389 groupIdnet.bramp.ffmpeg/groupId
390 artifactIdffmpeg/artifactId
391 version0.6.2/version
392 /dependency
393
394 !-- https://mvnrepository.com/artifact/org.apache.poi/poi --
395 dependency
396 groupIdorg.apache.poi/groupId
397 artifactIdpoi/artifactId
398 version3.17/version
399 /dependency
400
401 !-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --
402 dependency
403 groupIdorg.apache.poi/groupId
404 artifactIdpoi-ooxml/artifactId
405 version3.17/version
406 /dependency
407
408 !-- https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad --
409 dependency
410 groupIdorg.apache.poi/groupId
411 artifactIdpoi-scratchpad/artifactId
412 version3.17/version
413 /dependency
414
415 /dependencies
416
417 /project web.xml 1 ?xml version1.0 encodingUTF-8?2 web-app xmlnshttp://xmlns.jcp.org/xml/ns/javaee3 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance4 xsi:schemaLocationhttp://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd5 version3.16 7 !-- Session --8 filter9 filter-namespringSessionRepositoryFilter/filter-name
10 filter-classorg.springframework.web.filter.DelegatingFilterProxy/filter-class
11 /filter
12 filter-mapping
13 filter-namespringSessionRepositoryFilter/filter-name
14 url-pattern/*/url-pattern
15 dispatcherREQUEST/dispatcher
16 dispatcherERROR/dispatcher
17 /filter-mapping
18
19 servlet
20 servlet-namedispatcher/servlet-name
21 servlet-classorg.springframework.web.servlet.DispatcherServlet/servlet-class
22 !--init-param--
23 !--param-namecontextConfigLocation/param-name--
24 !--param-value/WEB-INF/applicationContext.xml/param-value--
25 !--/init-param--
26 load-on-startup1/load-on-startup
27 /servlet
28
29 servlet-mapping
30 servlet-namedispatcher/servlet-name
31 url-pattern//url-pattern
32 /servlet-mapping
33
34 filter
35 filter-nameencodingFilter/filter-name
36 filter-classorg.springframework.web.filter.CharacterEncodingFilter/filter-class
37 init-param
38 param-nameencoding/param-name
39 param-valueUTF-8/param-value
40 /init-param
41 init-param
42 param-nameforceEncoding/param-name
43 param-valuetrue/param-value
44 /init-param
45 /filter
46 filter-mapping
47 filter-nameencodingFilter/filter-name
48 url-pattern/*/url-pattern
49 /filter-mapping
50
51 context-param
52 param-namecontextConfigLocation/param-name
53 param-value/WEB-INF/applicationContext.xml/param-value
54 /context-param
55
56 context-param
57 param-namelog4jConfiguration/param-name
58 !-- 日志配置文件路径请根据具体项目自行调整 --
59 param-valueclasspath:META-INF/log4j2.xml/param-value
60 /context-param
61
62 listener
63 listener-classorg.springframework.web.context.ContextLoaderListener/listener-class
64 /listener
65
66 /web-app applicationContext.xml 1 ?xml version1.0 encodingUTF-8?2 beans xmlnshttp://www.springframework.org/schema/beans3 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance4 xmlns:contexthttp://www.springframework.org/schema/context5 xmlns:mongohttp://www.springframework.org/schema/data/mongo6 xmlns:cachehttp://www.springframework.org/schema/cache7 xsi:schemaLocationhttp://www.springframework.org/schema/beans8 http://www.springframework.org/schema/beans/spring-beans.xsd9 http://www.springframework.org/schema/context10 http://www.springframework.org/schema/context/spring-context-2.5.xsd11 http://www.springframework.org/schema/data/mongo12 http://www.springframework.org/schema/data/mongo/spring-mongo.xsd13 http://www.springframework.org/schema/cache14 http://www.springframework.org/schema/cache/spring-cache-3.1.xsd15 16 context:property-placeholder locationclasspath*:META-INF/config.properties/17 18 !-- SpringData类型转换器 --19 !--mongo:mapping-converter idmongoConverter--20 !--mongo:custom-converters--21 !--mongo:converter--22 !--bean classcom.jastar.demo.converter.TimestampConverter /--23 !--/mongo:converter--24 !--/mongo:custom-converters--25 !--/mongo:mapping-converter--26 27 mongo:mongo-client idmongo host${mongo.host} port${mongo.port}28 mongo:client-options connections-per-host${mongo.connectionsPerHost}29 threads-allowed-to-block-for-connection-multiplier${mongo.threadsAllowedToBlockForConnectionMultiplier}30 connect-timeout${mongo.connectTimeout} max-wait-time${mongo.maxWaitTime}31 socket-keep-alive${mongo.socketKeepAlive} socket-timeout${mongo.socketTimeout}/32 /mongo:mongo-client33 !-- mongo的工厂通过它来取得mongo实例,dbname为mongodb的数据库名没有的话会自动创建 --34 mongo:db-factory idmongoDbFactory dbname${mongo.dbname}35 mongo-refmongo/36 37 !-- mongodb的主要操作对象所有对mongodb的增删改查的操作都是通过它完成 --38 bean idmongoTemplate classorg.springframework.data.mongodb.core.MongoTemplate39 constructor-arg namemongoDbFactory refmongoDbFactory/40 !--constructor-arg namemongoConverter refmongoConverter /--41 /bean42 43 context:component-scan base-packagecom.company.framework.dao/44 45 mongo:repositories base-packagecom.company.framework.dao/46 47 !-- redis数据源 --48 bean idjedisPoolConfig classredis.clients.jedis.JedisPoolConfig49 !-- 池中可借的最大数 --50 property namemaxTotal value${redis.maxTotal}/51 !-- 允许池中空闲的最大连接数 --52 property namemaxIdle value${redis.maxIdle}/53 !-- 允许池中空闲的最小连接数 --54 property nameminIdle value${redis.minIdle}/55 !-- 获取连接最大等待时间毫秒 --56 property namemaxWaitMillis value${redis.maxWaitMillis}/57 !-- 当maxActive到达最大数获取连接时的操作 是否阻塞等待 --58 property nameblockWhenExhausted value${redis.blockWhenExhausted}/59 !-- 在获取连接时是否验证有效性 --60 property nametestOnBorrow value${redis.testOnBorrow}/61 !-- 在归还连接时是否验证有效性 --62 property nametestOnReturn value${redis.testOnReturn}/63 !-- 当连接空闲时是否验证有效性 --64 property nametestWhileIdle value${redis.testWhileIdle}/65 !-- 设定间隔没过多少毫秒进行一次后台连接清理的行动 --66 property nametimeBetweenEvictionRunsMillis value${redis.timeBetweenEvictionRunsMillis}/67 !-- 每次检查的连接数 --68 property namenumTestsPerEvictionRun value${redis.numTestsPerEvictionRun}/69 /bean70 71 !-- Spring-redis连接池管理工厂 --72 bean idjedisConnectionFactory classorg.springframework.data.redis.connection.jedis.JedisConnectionFactory73 !-- IP地址 --74 property namehostName value${redis.hostName}/75 !-- 端口号 --76 property nameport value${redis.port}/77 !-- 超时时间 默认2000--78 property nametimeout value${redis.timeout}/79 !-- 连接池配置引用 --80 property namepoolConfig refjedisPoolConfig /81 !-- usePool是否使用连接池 --82 property nameusePool valuetrue/83 /bean84 85 bean idredisTemplate classorg.springframework.data.redis.core.RedisTemplate86 property nameconnectionFactory refjedisConnectionFactory/87 property namekeySerializer88 bean classorg.springframework.data.redis.serializer.StringRedisSerializer /89 /property90 property namevalueSerializer91 bean classorg.springframework.data.redis.serializer.JdkSerializationRedisSerializer /92 /property93 property namehashKeySerializer94 bean classorg.springframework.data.redis.serializer.StringRedisSerializer /95 /property96 property namehashValueSerializer97 bean classorg.springframework.data.redis.serializer.JdkSerializationRedisSerializer /98 /property99 !--开启事务 --
100 property nameenableTransactionSupport valuetrue/property
101 /bean
102
103 bean idredisHttpSessionConfiguration
104 classorg.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration/
105
106
107 cache:annotation-driven cache-managercacheManager /
108
109 bean idcacheManager classorg.springframework.cache.ehcache.EhCacheCacheManager
110 property namecacheManager refehcache/property
111 /bean
112
113 bean idehcache classorg.springframework.cache.ehcache.EhCacheManagerFactoryBean
114 property nameconfigLocation valueclasspath:META-INF/ehcache-setting.xml/property
115 /bean
116
117 /beans dispatcher-servlet.xml 1 ?xml version1.0 encodingUTF-8?2 beans xmlnshttp://www.springframework.org/schema/beans3 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance4 xmlns:contexthttp://www.springframework.org/schema/context5 xmlns:mvchttp://www.springframework.org/schema/mvc6 xmlns:jpahttp://www.springframework.org/schema/data/jpa7 xmlns:txhttp://www.springframework.org/schema/tx8 xsi:schemaLocationhttp://www.springframework.org/schema/beans9 http://www.springframework.org/schema/beans/spring-beans.xsd
10 http://www.springframework.org/schema/context
11 http://www.springframework.org/schema/context/spring-context.xsd
12 http://www.springframework.org/schema/mvc
13 http://www.springframework.org/schema/mvc/spring-mvc.xsd
14 http://www.springframework.org/schema/data/jpa
15 http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd
16 http://www.springframework.org/schema/tx
17 http://www.springframework.org/schema/tx/spring-tx.xsd
18
19 context:component-scan base-packagecom.company.framework.component/
20
21 context:component-scan base-packagecom.company.framework.service/
22
23 !--指明 controller 所在包并扫描其中的注解--
24 context:component-scan base-packagecom.company.framework.controller/
25
26 !-- 静态资源(js、image等)的访问 --
27 mvc:default-servlet-handler/
28
29 !-- 开启注解 --
30 mvc:annotation-driven/
31
32 !--ViewResolver 视图解析器--
33 !--用于支持Servlet、JSP视图解析--
34 bean idjspViewResolver classorg.springframework.web.servlet.view.InternalResourceViewResolver
35 property nameviewClass valueorg.springframework.web.servlet.view.JstlView/
36 property nameprefix value/WEB-INF/pages//
37 property namesuffix value.jsp/
38 /bean
39
40 !-- 表示JPA Repository所在的包 --
41 !--jpa:repositories base-packagecom.company.framework.dao2/--
42
43 !--bean identityManagerFactory classorg.springframework.orm.jpa.LocalEntityManagerFactoryBean--
44 !--property namepersistenceUnitName valuedefaultPersistenceUnit/--
45 !--/bean--
46
47 !-- 事务管理 --
48 !--bean idtransactionManager classorg.springframework.orm.jpa.JpaTransactionManager--
49 !--property nameentityManagerFactory refentityManagerFactory/--
50 !--/bean--
51
52 !--tx:annotation-driven transaction-managertransactionManager/--
53
54 !-- make spring look up annotation --
55 context:annotation-config/
56
57 /beans ehcache-setting.xml 1 ?xml version1.0 encodingUTF-8?2 ehcache3 !-- 指定一个文件目录当EhCache把数据写到硬盘上时将把数据写到这个文件目录下 --4 diskStore pathjava.io.tmpdir/5 6 !--name缓存名称--7 !--maxElementsInMemory内存中最大缓存对象数--8 !--maxElementsOnDisk硬盘中最大缓存对象数若是0表示无穷大--9 !--eternaltrue表示对象永不过期此时会忽略timeToIdleSeconds和timeToLiveSeconds属性默认为false--
10 !--overflowToDisktrue表示当内存缓存的对象数目达到了--
11 !--maxElementsInMemory界限后会把溢出的对象写到硬盘缓存中。注意如果缓存的对象要写入到硬盘中的话则该对象必须实现了Serializable接口才行。--
12 !--diskSpoolBufferSizeMB磁盘缓存区大小默认为30MB。每个Cache都应该有自己的一个缓存区。--
13 !--diskPersistent是否缓存虚拟机重启期数据是否持久化磁盘缓存,当这个属性的值为true时,系统在初始化时会在磁盘中查找文件名 为cache名称,后缀名为index的文件这个文件中存放了已经持久化在磁盘中的cache的index,找到后会把cache加载到内存要想把 cache真正持久化到磁盘,写程序时注意执行net.sf.ehcache.Cache.put(Element element)后要调用flush()方法。--
14 !--diskExpiryThreadIntervalSeconds磁盘失效线程运行时间间隔默认为120秒--
15 !--timeToIdleSeconds 设定允许对象处于空闲状态的最长时间以秒为单位。当对象自从最近一次被访问后如果处于空闲状态的时间超过了timeToIdleSeconds属性 值这个对象就会过期EHCache将把它从缓存中清空。只有当eternal属性为false该属性才有效。如果该属性值为0则表示对象可以无限 期地处于空闲状态--
16 !--timeToLiveSeconds设定对象允许存在于缓存中的最长时间以秒为单位。当对象自从被存放到缓存中后如果处于缓存中的时间超过了 timeToLiveSeconds属性值这个对象就会过期EHCache将把它从缓存中清除。只有当eternal属性为false该属性才有 效。如果该属性值为0则表示对象可以无限期地存在于缓存中。timeToLiveSeconds必须大于timeToIdleSeconds属性才有 意义--
17 !--memoryStoreEvictionPolicy当达到maxElementsInMemory限制时Ehcache将会根据指定的策略去清理内存。可选策略有LRU最近最少使用默认策略、FIFO先进先出、LFU最少访问次数。--
18
19 !-- 设定缓存的默认数据过期策略 --
20 defaultCache
21 maxElementsInMemory10000
22 eternalfalse
23 overflowToDisktrue
24 timeToIdleSeconds10
25 timeToLiveSeconds20
26 diskPersistentfalse
27 diskExpiryThreadIntervalSeconds120/
28
29 cache namecache
30 maxElementsInMemory10000
31 eternalfalse
32 overflowToDisktrue
33 timeToIdleSeconds10
34 timeToLiveSeconds20/
35
36 /ehcache log4j2.xml 1 ?xml version1.0 encodingUTF-8?2 !--日志级别以及优先级排序: OFF FATAL ERROR WARN INFO DEBUG TRACE ALL --3 !--Configuration后面的status这个用于设置log4j2自身内部的信息输出可以不设置当设置成trace时你会看到log4j2内部各种详细输出--4 !--monitorIntervalLog4j能够自动检测修改配置 文件和重新配置本身设置间隔秒数--5 configuration statusWARN monitorInterval306 !--先定义所有的appender--7 appenders8 !--这个输出控制台的配置--9 console nameConsole targetSYSTEM_OUT
10 !--输出日志的格式--
11 PatternLayout pattern[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n/
12 /console
13 !--文件会打印出所有信息这个log每次运行程序会自动清空由append属性决定这个也挺有用的适合临时测试用--
14 File namelog fileNamelog/test.log appendfalse
15 PatternLayout pattern%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n/
16 /File
17 !-- 这个会打印出所有的info及以下级别的信息每次大小超过size则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩作为存档--
18 RollingFile nameRollingFileInfo fileName${sys:user.home}/logs/info.log
19 filePattern${sys:user.home}/logs/$${date:yyyy-MM}/info-%d{yyyy-MM-dd}-%i.log
20 !--控制台只输出level及以上级别的信息onMatch其他的直接拒绝onMismatch--
21 ThresholdFilter levelinfo onMatchACCEPT onMismatchDENY/
22 PatternLayout pattern[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n/
23 Policies
24 TimeBasedTriggeringPolicy/
25 SizeBasedTriggeringPolicy size100 MB/
26 /Policies
27 /RollingFile
28 RollingFile nameRollingFileWarn fileName${sys:user.home}/logs/warn.log
29 filePattern${sys:user.home}/logs/$${date:yyyy-MM}/warn-%d{yyyy-MM-dd}-%i.log
30 ThresholdFilter levelwarn onMatchACCEPT onMismatchDENY/
31 PatternLayout pattern[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n/
32 Policies
33 TimeBasedTriggeringPolicy/
34 SizeBasedTriggeringPolicy size100 MB/
35 /Policies
36 !-- DefaultRolloverStrategy属性如不设置则默认为最多同一文件夹下7个文件这里设置了20 --
37 DefaultRolloverStrategy max20/
38 /RollingFile
39 RollingFile nameRollingFileError fileName${sys:user.home}/logs/error.log
40 filePattern${sys:user.home}/logs/$${date:yyyy-MM}/error-%d{yyyy-MM-dd}-%i.log
41 ThresholdFilter levelerror onMatchACCEPT onMismatchDENY/
42 PatternLayout pattern[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n/
43 Policies
44 TimeBasedTriggeringPolicy/
45 SizeBasedTriggeringPolicy size100 MB/
46 /Policies
47 /RollingFile
48 /appenders
49 !--然后定义logger只有定义了logger并引入的appenderappender才会生效--
50 loggers
51 !--过滤掉spring和mybatis的一些无用的DEBUG信息--
52 logger nameorg.springframework levelINFO/logger
53 logger nameorg.hibernate levelINFO/logger
54 logger nameorg.mongodb.driver levelINFO /
55 logger nameorg.mongodb.driver.cluster levelOFF /
56 root leveldebug
57 appender-ref refConsole/
58 appender-ref refRollingFileInfo/
59 appender-ref refRollingFileWarn/
60 appender-ref refRollingFileError/
61 /root
62 /loggers
63 /configuration config.properties 1 ###---The mongodb settings--- 2 mongo.dbnameadmin3 mongo.host127.0.0.14 mongo.port270175 mongo.connectionsPerHost86 mongo.threadsAllowedToBlockForConnectionMultiplier47 mongo.connectTimeout10008 mongo.maxWaitTime15009 mongo.autoConnectRetrytrue
10 mongo.socketKeepAlivetrue
11 mongo.socketTimeout1500
12 mongo.slaveOktrue
13 mongo.writeNumber1
14 mongo.writeTimeout0
15 mongo.writeFsynctrue
16
17 ###---The redis settings---
18 redis.hostName127.0.0.1
19 redis.port6379
20 redis.password
21 redis.maxTotal6000
22 redis.maxIdle400
23 redis.minIdle2
24 redis.maxWaitMillis1000
25 redis.blockWhenExhaustedtrue
26 redis.testOnBorrowtrue
27 redis.testOnReturntrue
28 redis.testWhileIdletrue
29 redis.timeBetweenEvictionRunsMillis1800000
30 redis.numTestsPerEvictionRun5
31 redis.timeout100000
32 defaultCacheExpireTime60 转载于:https://www.cnblogs.com/clockdotnet/p/JavaSpringProject.html