<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath/>
</parent>
<!-- <parent> <groupId>com.jzlife.management</groupId> <artifactId>service-os</artifactId>
<version>0.0.1-SNAPSHOT</version> <relativePath>../service-os/pom.xml</relativePath>
</parent> -->
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<artifactId>zuul-apigateway</artifactId>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>zuulapigateway</finalName>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<verbose />
<bootclasspath>${env.JAVA_HOME}/jre/lib/rt.jar</bootclasspath>
<extdirs>${project.basedir}/src/main/webapp/WEB-INF/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<!-- <version>2.7</version> -->
<executions>
<execution>
<id>default-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target/classes</outputDirectory>
<useDefaultDelimiters>false</useDefaultDelimiters>
<delimiters>
<delimiter>#</delimiter>
</delimiters>
<resources>
<resource>
<directory>src/main/resources/</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources.${spring.profiles.active}</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<!--开发环境 -->
<profile>
<id>dev</id>
<properties>
<spring.profiles.active>dev</spring.profiles.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<properties>
<spring.profiles.active>test</spring.profiles.active>
</properties>
</profile>
<!--生产环境 -->
<profile>
<id>pro</id>
<properties>
<spring.profiles.active>pro</spring.profiles.active>
</properties>
</profile>
<!--线上测试环境 -->
<profile>
<id>uat</id>
<properties>
<spring.profiles.active>uat</spring.profiles.active>
</properties>
</profile>
</profiles>
</project>
application.yml
spring:
application:
name: zuul-api
profiles:
active: #spring.profiles.active#
# security:
# user:
# name: "admin"
# password: "qazplm123"
server:
port: 18770
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 60000
management:
endpoints:
enabled: false
web:
exposure:
include: '*'
endpoint:
health:
show-details: ALWAYS
dev.yml
eureka:
client:
service-url:
defaultZone: http://${spring.cloud.client.ipaddress}:18760/eureka/
instance:
hostname: localhost
status-page-url: http://${spring.cloud.client.ipaddress}:${server.port}
instance-id: zuul-apigateway(${spring.cloud.client.ipaddress}:${server.port})
preferIpAddress: true
leaseRenewalIntervalInSeconds: 10
leaseExpirationDurationInSeconds: 30
# metadata-map:
# user.name: ${spring.security.user.name}
# user.password: ${spring.security.user.password}
spring:
cloud:
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
logging:
level:
root: info
org.mybatis: debug
file: "logs/zuulapilog.log"
layout: org.apache.log4j.PatternLayout
ConversionPattern: "%d{yyyy-MM-dd HH:mm:ss} %5p %c %t: - %m%n"
application.java
package com.jzlife.management;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
/**
*
* <p>Title: ZullApiGetwayApplication</p>
* <p>Description: </p>
* @author lurz
* @date 2019年2月21日
*/
//@EnableDiscoveryClient
@EnableEurekaClient
@SpringBootApplication
//@EnableAdminServer
public class ZullApiGetwayApplication {
public static void main(String[] args) {
SpringApplication.run(ZullApiGetwayApplication.class, args);
}
}