公众平台测试帐号开发全流程第2篇-搭建项目
来源:互联网 发布:淘宝拒收快递运费谁出 编辑:程序博客网 时间:2024/06/01 08:38
这个项目我就在eclipse里用springmvc来开发吧。嗯,用maven来管理比较方便些,jar包添加进去就好了。
步骤
先选择maven项目
把Create a simple project 的选项勾上
这边需要注意一下,Artifact Id 才是项目名称
这时,项目出现一个叉叉,不要怕是应为没有web.xml文件,只需要添加一个就好了
接下来添加jar包,如下图添加
下面就是暂时所需要的jar包
web.xml的内容
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <!-- 区分项目名称,防止默认重名 --> <context-param> <param-name>webAppRootKey</param-name> <param-value>weChatPlatform</param-value> </context-param> <!-- 日志 --> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>classpath:/com/weChatPlatform/config/log4j.properties</param-value> </context-param> <!-- Spring的log4j监听器 --> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <servlet> <servlet-name>systemInit</servlet-name> <servlet-class>com.weChatPlatform.other.SystemInit</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- 字符集 过滤器 --> <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <!-- <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> --> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Spring view分发器 --> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:/com/weChatPlatform/config/dispatcher-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!-- 主页 --> <welcome-file-list> <welcome-file> index.html </welcome-file> </welcome-file-list></web-app>
spring配置文件的内容及位置
<?xml version="1.0" encoding="UTF-8"?><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:mvc="http://www.springframework.org/schema/mvc" 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.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <!-- 默认注解映射支持 --> <mvc:annotation-driven /> <context:component-scan base-package="com.weChatPlatform" /> <!-- 配置freeMarker的模板路径 --> <bean id="freemarkerConfigurer" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="templateLoaderPath" value="/WEB-INF/html/" /> <property name="defaultEncoding" value="UTF-8" /> </bean> <!-- freemarker视图解析器 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> <property name="suffix" value=".html" /> <property name="contentType" value="text/html;charset=UTF-8" /> </bean></beans>
日志配置文件的内容
log4j.rootLogger=ERROR,console,FILEOUTlog4j.appender.console=org.apache.log4j.ConsoleAppenderlog4j.appender.Threshold=ERRORlog4j.appender.CONSOLE.Target=System.out log4j.appender.console.layout=org.apache.log4j.PatternLayoutlog4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%5p] (%F:%L) - %m%nlog4j.appender.FILEOUT=org.apache.log4j.RollingFileAppender log4j.appender.FILEOUT.File=${logsFile}/file.log #log4j.appender.fileout.MaxFileSize=100000KB # default is true£¬append to the file; if false, the replace the log file whenever restart system log4j.appender.FILEOUT.Append=true #RollingFileAppenderûÓÐDatePatternÕâ¸öÊôÐÔ log4j.appender.FILEOUT.layout=org.apache.log4j.PatternLayout #log4j.appender.CONSOLE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n log4j.appender.FILEOUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%5p] (%F:%L) - %m%nlog4j.logger.freemarker=FATAL
到了这里这个项目差不多搭建好了,关于数据库连接还没想好用哪个框架,个人比较倾向于mybatis,后续再添加上。
0 0
- 公众平台测试帐号开发全流程第2篇-搭建项目
- 公众平台测试帐号开发全流程第1篇-引言
- 公众平台测试帐号开发全流程第3篇-接入
- 公众平台测试帐号开发全流程第4篇-自定义菜单
- 公众平台测试帐号开发全流程第5篇-消息
- 公众平台测试帐号开发全流程第6篇-接收和被动回复消息
- 公众平台测试帐号开发全流程第7篇-用户管理
- 公众平台测试帐号开发全流程第7篇-用户管理之用户分组管理
- 公众平台测试帐号开发全流程第8篇-素材管理
- 公众平台测试帐号开发全流程第9篇-模板消息
- [037] 微信公众帐号开发教程第13篇-图文消息全攻略
- 微信公众帐号开发教程第13篇-图文消息全攻略 -- 转载
- 微信公众帐号开发教程第13篇-图文消息全攻略
- [037] 微信公众帐号开发教程第13篇-图文消息全攻略 .
- 微信公众帐号开发教程第13篇-图文消息全攻略 (13)
- 微信公众帐号开发教程第13篇-图文消息全攻略
- 微信公众帐号开发教程第13篇-图文消息全攻略 (Java版)
- 微信公众帐号开发教程第13篇-图文消息全攻略
- 常见的xml里的转义字符
- 积少成多
- document.documentElement和document.body
- 习题6-2 UVA 712 S-Trees S树
- System函数
- 公众平台测试帐号开发全流程第2篇-搭建项目
- linux下用tomcat部署产品
- Hibernate框架核心组件
- html5优越性
- DiaLogUtils报错java.lang. IllegalStateException You need to use a Theme.AppCompat theme
- 关于C艹中的笑脸问题。
- 【工作技巧】word目录
- 我的博客
- poj 3187 Backward Digit Sums(全排列变形)