rose 框架的搭建(天创信用)
Posted yuanpeng-java
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了rose 框架的搭建(天创信用)相关的知识,希望对你有一定的参考价值。
1.新建一个maven 的 war 工程
2.引入 pom 文件
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 <modelVersion>4.0.0</modelVersion> 4 <groupId>com.tcredit</groupId> 5 <artifactId>mobile</artifactId> 6 <version>0.0.1-SNAPSHOT</version> 7 <packaging>war</packaging> 8 <!-- 引入 rose 父项目:定义 maven 仓库的位置,默认读取配置文件的位置,打包编码格式, java 版本等等 --> 9 <parent> 10 <groupId>com.wzzx</groupId> 11 <artifactId>wzzx-root-pom</artifactId> 12 <version>1.0.0-SNAPSHOT</version> 13 </parent> 14 <!-- jar包版本号管理 --> 15 <dependencyManagement> 16 <dependencies> 17 <dependency> 18 <groupId>com.wzzx</groupId> 19 <artifactId>wzzx-rose-pom</artifactId> 20 <version>1.3.0-SNAPSHOT</version> 21 <type>pom</type> 22 <scope>import</scope> 23 </dependency> 24 </dependencies> 25 </dependencyManagement> 26 <!-- 引入依赖 --> 27 <dependencies> 28 <!--Rose --> 29 <dependency> 30 <groupId>com.wzzx</groupId> 31 <artifactId>wzzx-web-core</artifactId> 32 <version>1.0.0-SNAPSHOT</version> 33 </dependency> 34 <dependency> 35 <groupId>net.paoding</groupId> 36 <artifactId>rose-pipe</artifactId> 37 </dependency> 38 <dependency> 39 <groupId>net.paoding</groupId> 40 <artifactId>rose</artifactId> 41 </dependency> 42 <dependency> 43 <groupId>org.projectlombok</groupId> 44 <artifactId>lombok</artifactId> 45 <version>1.16.18</version> 46 </dependency> 47 </dependencies> 48 <profiles> 49 <!-- 开发,默认激活 --> 50 <profile> 51 <id>dev</id> 52 <properties> 53 <env>dev</env> 54 <env-s>-dev</env-s> 55 </properties> 56 <activation> 57 <activeByDefault>true</activeByDefault> 58 </activation> 59 </profile> 60 <profile> 61 <id>mock</id> 62 <properties> 63 <env>mock</env> 64 <env-s>-mock</env-s> 65 </properties> 66 67 </profile> 68 <profile> 69 <id>test</id> 70 <properties> 71 <env>test</env> 72 <env-s>-test</env-s> 73 </properties> 74 </profile> 75 <profile> 76 <id>uat</id> 77 <properties> 78 <env>uat</env> 79 <env-s>-uat</env-s> 80 </properties> 81 </profile> 82 <profile> 83 <id>prod</id> 84 <properties> 85 <env>prod</env> 86 <env-s></env-s> 87 </properties> 88 </profile> 89 </profiles> 90 <!-- 构建配置 --> 91 <build> 92 <finalName>${project.artifactId}-${project.version}</finalName> 93 <defaultGoal>compile</defaultGoal> 94 <filters> 95 <filter>${project.basedir}/filters/${env}/config.properties</filter> 96 </filters> 97 <resources> 98 <resource> 99 <directory>src/main/resources</directory> 100 <filtering>true</filtering> 101 <includes> 102 <!--需要过滤的文件 --> 103 <include>*.*</include> 104 </includes> 105 </resource> 106 <resource> 107 <directory>src/main/resources</directory> 108 <filtering>false</filtering> 109 <excludes> 110 <exclude>*.*</exclude> 111 </excludes> 112 </resource> 113 </resources> 114 </build> 115 116 117 </project>
3.配置 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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>mobile</display-name> <!-- 前端字符编码过滤器 --> <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class>com.wzzx.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- rose 过滤器 --> <filter> <filter-name>roseFilter</filter-name> <filter-class>net.paoding.rose.RoseFilter</filter-class> </filter> <filter-mapping> <filter-name>roseFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app>
4.配置 applicationContext 文件
<?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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd"> <context:component-scan base-package="com.tcredit.mobile"></context:component-scan> </beans>
5.配置 datasoure.yaml 文件
#公司环境数据库配置
auth:
root : root
#######################################
#mysql的默认连接配置
default:
type: mysql
port: 3306
initialSize: 1
maxActive: 20
maxWait: 10000
filters:
- stat
auth: root
#######################################
server:
#mysql服务
mobile:
host: ${mobile_host}
datasource:
mobile:
server: mobile
database: ${mobile_database}
auth: root
6.配置setting 文件
jade.datasource=datasource.yaml
7.配置 filter dev config.properties 文件
#mysql服务
mobile_host=127.0.0.1
#datasource:
mobile_database=mobile
#数据库文件的位置
jade.datasource=datasource.yaml
8.新建 pojo,dao,service,interface,contorller 文件,并启动项目服务器
以上是关于rose 框架的搭建(天创信用)的主要内容,如果未能解决你的问题,请参考以下文章