首页 > 安全资讯 >

仓库管理系统系列——2、环境搭建和配置文件

16-06-18

拦截器也有两种配置方法,具体见xml文件和注释,在本项目采取的方法中,其中的property属性需要注意,它采用一个list来配置该拦截器不需要拦截的Uri。因为拦截器并没有提供反向排除的配置方式,故先拦截所有,然后在拦截器中剔除部分。

一、系统所依赖的Jar包。

antlr-2.7.7.jar

aspectjrt.jar

aspectjweaver.jar
c3p0-0.9.2.1.jar
classmate-1.3.0.jar
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar
com.springsource.org.apache.commons.pool-1.5.3.jar
commons-beanutils-1.8.3.jar
commons-collections-3.2.1.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
commons-logging.jar
dom4j-1.6.1.jar
ezmorph-1.0.6.jar
geronimo-jta_1.1_spec-1.1.1.jar
hibernate-c3p0-4.3.11.Final.jar
hibernate-commons-annotations-4.0.5.Final.jar
hibernate-core-4.3.11.Final.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
hibernate-validator-5.0.3.Final.jar
jackson-annotations-2.5.0.jar
jackson-core-2.5.0.jar
jackson-databind-2.5.0.jar
jandex-1.1.0.Final.jar
javassist-3.18.1-GA.jar
jboss-logging-3.1.3.GA.jar
jboss-logging-annotations-1.2.0.Beta1.jar
jboss-transaction-api_1.2_spec-1.0.0.Final.jar
json-lib-2.4-jdk15.jar
log4j-1.2.17.jar
mchange-commons-java-0.2.3.4.jar
mysql-connector-java-5.1.38-bin.jar
slf4j-api-1.6.1.jar
spring-aop-4.0.0.RELEASE.jar
spring-aspects-4.0.0.RELEASE.jar
spring-beans-4.0.0.RELEASE.jar
spring-context-4.0.0.RELEASE.jar
spring-context-support-4.0.0.RELEASE.jar
spring-core-4.0.0.RELEASE.jar
spring-expression-4.0.0.RELEASE.jar
spring-framework-bom-4.0.0.RELEASE.jar
spring-instrument-4.0.0.RELEASE.jar
spring-instrument-tomcat-4.0.0.RELEASE.jar
spring-jdbc-4.0.0.RELEASE.jar
spring-jms-4.0.0.RELEASE.jar
spring-messaging-4.0.0.RELEASE.jar
spring-orm-4.0.0.RELEASE.jar
spring-oxm-4.0.0.RELEASE.jar
spring-test-4.0.0.RELEASE.jar
spring-tx-4.0.0.RELEASE.jar
spring-web-4.0.0.RELEASE.jar
spring-webmvc-4.0.0.RELEASE-sources.jar
spring-webmvc-4.0.0.RELEASE.jar
spring-webmvc-portlet-4.0.0.RELEASE.jar
spring-websocket-4.0.0.RELEASE.jar
validation-api-1.1.0.Final.jar

二、web.xml配置

 



	StoreManagerSystem-MVC
	
		index.html
		index.htm
		index.jsp
		default.html
		default.htm
		default.jsp
	

	
	
		log4jConfigLocation
		classpath:log4j.properties
	
	
		log4jRefreshInterval
		3000
	
	
	
	
	
		encoding
		org.springframework.web.filter.CharacterEncodingFilter
		
			encoding
			UTF-8
		
	
	
		encoding
		/
	
	
	
	
	
		spring
		org.springframework.web.servlet.DispatcherServlet
		
			contextConfigLocation
			/WEB-INF/spring-servlet.xml
		
		1
	
	
		spring
		/
	
	
	
	
	  
          
            org.springframework.web.util.Log4jConfigListener  
          
      

	
	
	

说明几点:

 

1、日志采用log4j工具输出,包括输出到Console和本地文件,log4j.properties文件位于classpath路径下面,所以在Web.xml中需要加载该文件,包括配置文件的路径和加载该文件的listener

log4j.properties内容如下

 

###Root Logger DEBUG < INFO < WARN < ERROR < FATAL
log4j.rootLogger=INFO,console,dailyFile,logFile
log4j.additivity.org.apache=true

### console 
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Threshold=INFO
log4j.appender.console.ImmediateFlush=true
log4j.appender.console.Target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n

### logFile
log4j.appender.logFile=org.apache.log4j.FileAppender
log4j.appender.logFile.Threshold=INFO
log4j.appender.logFile.ImmediateFlush=true
log4j.appender.logFile.Append=true
log4j.appender.logFile.File=E:/ManagerSystem/logs/log/log.log4j
log4j.appender.logFile.layout=org.apache.log4j.PatternLayout
log4j.appender.logFile.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n

### rollingFile
log4j.appender.rollingFile=org.apache.log4j.RollingFileAppender
log4j.appender.rollingFile.Threshold=INFO
log4j.appender.rollingFile.ImmediateFlush=true
log4j.appender.rollingFile.Append=true
log4j.appender.rollingFile.File=E:/ManagerSystem/logs/rolling/log.log4j
log4j.appender.rollingFile.MaxFileSize=200KB
log4j.appender.rollingFile.MaxBackupIndex=50
log4j.appender.rollingFile.layout=org.apache.log4j.PatternLayout
log4j.appender.rollingFile.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n

### dailyFile
## '.'yyyy-MM           # every month
## '.'yyyy-ww           # every week
## '.'yyyy-MM-dd        # every day
## '.'yyyy-MM-dd-a      # twice a day
## '.'yyyy-MM-dd-HH     # every hour
## '.'yyyy-MM-dd-HH-mm  # every minute
log4j.appender.dailyFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.dailyFile.Threshold=DEBUG
log4j.appender.dailyFile.ImmediateFlush=true
log4j.appender.dailyFile.Append=true
log4j.appender.dailyFile.File=E:/ManagerSystem/logs/daily/log.log4j
log4j.appender.dailyFile.DatePattern='.'yyyy-MM-dd
log4j.appender.dailyFile.layout=org.apache.log4j.PatternLayout
log4j.appender.dailyFile.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n

### spring default level
log4j.logger.org.springframework=INFO

### hibernate default level
log4j.logger.org.hibernate=INFO

### apache
log4j.logger.org.apache=ERROR
log4j.logger.net.sf.ehcache=ERROR

### socket
#log4j.appender.socket=org.apache.log4j.RollingFileAppender
#log4j.appender.socket.RemoteHost=localhost
#log4j.appender.socket.Port=5001
#log4j.appender.socket.LocationInfo=true

### Set up for Log Factor 5
#log4j.appender.socket.layout=org.apache.log4j.PatternLayout
#log4j.appender.socket.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n

### Log Factor 5 Appender
#log4j.appender.LF5_APPENDER=org.apache.log4j.lf5.LF5Appender
#log4j.appender.LF5_APPENDER.MaxNumberOfRecords=2000

### Email
#log4j.appender.mail=org.apache.log4j.net.SMTPAppender
#log4j.appender.mail.Threshold=FATAL
#log4j.appender.mail.BufferSize=10
#log4j.appender.mail.From = xxx@mail.com
#log4j.appender.mail.SMTPHost=mail.com
#log4j.appender.mail.Subject=Log4J Message
#log4j.appender.mail.To= xxx@mail.com
#log4j.appender.mail.layout=org.apache.log4j.PatternLayout
#log4j.appender.mail.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n

### Database
#log4j.appender.database=org.apache.log4j.jdbc.JDBCAppender
#log4j.appender.database.URL=jdbc:mysql://localhost:3306/test
#log4j.appender.database.driver=com.mysql.jdbc.Driver
#log4j.appender.database.user=root
#log4j.appender.database.password=
#log4j.appender.database.sql=INSERT INTO LOG4J (Message) VALUES('=[%-5p] %d(%r) --> [%t] %l: %m %x %n')
#log4j.appender.database.layout=org.apache.log4j.PatternLayout
#log4j.appender.database.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n

### Appender
#log4j.appender.im = net.cybercorlin.util.logger.appender.IMAppender
#log4j.appender.im.host = mail.cybercorlin.net
#log4j.appender.im.username = username
#log4j.appender.im.password = password
#log4j.appender.im.recipient = corlin@cybercorlin.net
#log4j.appender.im.layout=org.apache.log4j.PatternLayout
#log4j.appender.im.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n


 

2、项目统一采用UTF-8编码

3、Spring核心配置

 

	
		spring
		org.springframework.web.servlet.DispatcherServlet
		
			contextConfigLocation
			/WEB-INF/spring-servlet.xml
		
		1
	
	
		spring
		/
	

该配置的作用是,加载位于/WEB-INF目录下的spring-servlet.xml文件,并将所有请求交给DispatcherServlet处理。至于其详细的作用,请自行了解。

三、spring-servlet.xml配置

 

该配置问主要配置,包括项目所要用到的数据源(database)、操作数据库的session,管理session的事物(transaction),Bean、拦截器(Interceptor)、AOP以及视图解析器。

详细配置如下

 




	
	
	
		
		
		
		
		
		
		
		
		
		
		
		
		
		

		
		
		
		
		
		
		
		
		
		
		
		
		
	

	
	
	
		
			
		
		
			
				com/kl/napchen/store/bean/User.hbm.xml
				com/kl/napchen/store/bean/ProductIn.hbm.xml
				com/kl/napchen/store/bean/ProductOut.hbm.xml
				com/kl/napchen/store/bean/ProductType.hbm.xml
			
		
		
			
				
					org.hibernate.dialect.MySQL5Dialect
				
				update
				true
				true
				thread
			
		

		
		
		
		
		
		
	

	
	
	
		
		
	

	
	
	

	
	
	
		
			
			
			
			
		
	

	
		
		
	



	
	
	
	
	
	
	
	

	
	
	
	
	
	

	
	
	
	
	
	

	
	
	
	
	
	

	
	
	

	
	
	
	
	
	
	
	
	
	

	
	
	
	
	

	
	
	
	
	

	
	
	
	
	
	
	
	

	
	
	
	
	

	

	
	
	
	
	
	
	


	
	
	
	
	


	
	
	

	
	
		
		
		
		
		
	
.jpg.png.gif.ico.css.js.ttf.woff.woff2/index/register/login

 

说明

 

1、

	
	
	

	
	
	
		
			
			
			
			
		
	

	
		
		
	
采用注解的方式和采用AOP的方式都可以达到相同的目的。采用注解方式这需要用@transition注解标注service。

 


拦截器也有两种配置方法,具体见xml文件和注释,在本项目采取的方法中,其中的property属性需要注意,它采用一个list来配置该拦截器不需要拦截的Uri。因为拦截器并没有提供反向排除的配置方式,故先拦截所有,然后在拦截器中剔除部分。详细的剔除代码将在拦截器的Java代码中给出。

以上就是该项目的配置文件。




 

相关文章
最新文章
热点推荐