瀏覽代碼

环境隔离配置

sunyj 9 年之前
父節點
當前提交
d2b27fe18d

+ 34 - 5
pom.xml

@@ -8,6 +8,26 @@
 	<name>report Maven Webapp</name>
 	<url>http://maven.apache.org</url>
 
+	<profiles>
+		<!-- 开发环境 -->
+		<profile>
+			<id>dev</id>
+			<properties>
+				<profile>dev</profile>
+			</properties>
+			<activation>
+				<activeByDefault>true</activeByDefault>
+			</activation>
+		</profile>
+		<!-- 测试环境 -->
+		<profile>
+			<id>test</id>
+			<properties>
+				<profile>test</profile>
+			</properties>
+		</profile>
+	</profiles>
+
 	<properties>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<oracle.jdbc.version>11.2.0</oracle.jdbc.version>
@@ -21,7 +41,7 @@
 		<poi.version>3.10.1</poi.version>
 		<commons.fileupload.version>1.3.2</commons.fileupload.version>
 		<fastjson.version>1.1.39</fastjson.version>
-		<jasperserver.api.version>6.3.0</jasperserver.api.version>
+		<httpclient.version>4.5.2</httpclient.version>
 	</properties>
 
 	<dependencies>
@@ -96,19 +116,28 @@
 			<artifactId>commons-fileupload</artifactId>
 			<version>${commons.fileupload.version}</version>
 		</dependency>
-
 		<dependency>
 			<groupId>com.alibaba</groupId>
 			<artifactId>fastjson</artifactId>
 			<version>${fastjson.version}</version>
 		</dependency>
-
-		<!-- <dependency> <groupId>com.jaspersoft.jasperserver</groupId> <artifactId>jasperserver-api</artifactId> 
-			<version>${jasperserver.api.version}</version> </dependency> -->
+		<!-- HTTP请求 -->
+		<dependency>
+			<groupId>org.apache.httpcomponents</groupId>
+			<artifactId>httpclient</artifactId>
+			<version>${httpclient.version}</version>
+		</dependency>
 	</dependencies>
 
 	<build>
 		<finalName>report</finalName>
+		<!-- 受环境隔离影响的目录 -->
+		<resources>
+			<resource>
+				<directory>src/main/resources</directory>
+				<filtering>true</filtering>
+			</resource>
+		</resources>
 		<!-- 解决maven项目jre版本默认为1.5的问题 -->
 		<plugins>
 			<plugin>

+ 0 - 0
src/main/resources/jdbc.properties → src/main/resources/dev/jdbc.properties


+ 11 - 0
src/main/resources/dev/js-rest-api.properties

@@ -0,0 +1,11 @@
+schema=http
+host=localhost
+port=8081
+contextRoot=jasperserver
+rest=rest_v2
+resources=resources
+authorization=amFzcGVyYWRtaW46emh1aTEqOA==
+images=Picture
+localBaseDir=C:/sunyj/reports
+localImagesDir=/Picture
+localJrxmlDir=/jrxml

+ 0 - 0
src/main/resources/logging.properties → src/main/resources/dev/logging.properties


+ 0 - 5
src/main/resources/log4j.properties

@@ -1,5 +0,0 @@
-log4j.rootLogger=ERROR, stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d %5p %c:%L - %m%n

+ 3 - 1
src/main/resources/applicationContext.xml → src/main/resources/spring/applicationContext.xml

@@ -12,9 +12,11 @@
 	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
 	http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-4.1.xsd">
 
-	<context:property-placeholder location="classpath*:*.properties" />
+	<context:property-placeholder location="classpath*:${profile}/*.properties" />
 	<!-- 注册spring上下文对象 -->
 	<bean class="com.uas.report.support.ApplicationContextRegister" />
+	<!-- jasperserver rest_v2 api 相关参数注入 -->
+	<util:properties id="js_rest_api" location="classpath:${profile}/js-rest-api.properties" />
 
 	<!-- 扫描注解 -->
 	<context:annotation-config />

+ 11 - 0
src/main/resources/test/jdbc.properties

@@ -0,0 +1,11 @@
+jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
+jdbc.url=jdbc:oracle:thin:@192.168.253.6:1521:orcl
+jdbc.username=UAS
+jdbc.password=select!#%*(
+jdbc.initialSize=10
+jdbc.maxActive=100
+jdbc.maxIdle=50
+jdbc.minIdle=20
+jdbc.suspectTimeout=60
+jdbc.timeBetweenEvictionRunsMillis=30000
+jdbc.minEvictableIdleTimeMillis=60000

+ 11 - 0
src/main/resources/test/js-rest-api.properties

@@ -0,0 +1,11 @@
+schema=http
+host=192.168.253.60
+port=8080
+contextRoot=jasperserver
+rest=rest_v2
+resources=resources
+authorization=amFzcGVyYWRtaW46amFzcGVyYWRtaW4=
+images=Picture
+localBaseDir=/data/reports
+localImagesDir=/Picture
+localJrxmlDir=/jrxml

+ 15 - 0
src/main/resources/test/logging.properties

@@ -0,0 +1,15 @@
+#Tomcat Logger
+
+handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler   
+  
+############################################################   
+# Handler specific properties.   
+# Describes specific configuration info for Handlers.   
+############################################################   
+  
+org.apache.juli.FileHandler.level = FINE   
+org.apache.juli.FileHandler.directory = ${catalina.base}/logs   
+org.apache.juli.FileHandler.prefix = error-debug.   
+  
+java.util.logging.ConsoleHandler.level = FINE   
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

+ 2 - 2
src/main/webapp/WEB-INF/web.xml

@@ -7,7 +7,7 @@
 
 	<context-param>
 		<param-name>webAppRootKey</param-name>
-		<param-value>spring.webapp.report</param-value>
+		<param-value>report.root</param-value>
 	</context-param>
 	<context-param>
 		<param-name>spring.profiles.active</param-name>
@@ -23,7 +23,7 @@
 	</context-param>
 	<context-param>
 		<param-name>contextConfigLocation</param-name>
-		<param-value>classpath*:applicationContext.xml</param-value>
+		<param-value>classpath*:spring/applicationContext.xml</param-value>
 	</context-param>
 
 	<!-- filters -->