`
- 浏览:
228694 次
- 性别:
- 来自:
深圳
-
1.完整的pom.xml
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.soft.customer</groupId>
<artifactId>soft-customer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-cloud.version>Finchley.M9</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- spring cloud config 客户端包 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<!--Spring Boot Actuator,感应服务端变化 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<!--使用 ${spring.cloud.client.ip-address} 需引用下面的包-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
</dependency>
<!-- spring-redis 整合包start -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.6.2</version>
</dependency>
<!-- spring-redis 整合包end -->
<!-- connection pool start -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.17</version>
</dependency>
<!-- connection pool end -->
<!-- mybatis start -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<!-- mybatis end -->
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.60</version>
</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>soft-customer</finalName>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<outputDirectory>${basedir}/bin/classes</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/java</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>*.yml</include>
<include>*.sh</include>
</includes>
<targetPath>${basedir}/target</targetPath>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.soft.customer.CustomerApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/resources</outputDirectory>
<resources>
<resource>
<directory>${basedir}/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
2.完整的启动类
package com.soft.customer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;
import tk.mybatis.spring.annotation.MapperScan;
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@MapperScan({"com.soft.customer.dao"})
@ComponentScan({"com.soft.customer.*"})
@EnableScheduling
@EnableEurekaClient
@RefreshScope
public class CustomerApplication{
private static Logger logger = LoggerFactory.getLogger(CustomerApplication.class);
//开启均衡负载能力
@LoadBalanced
@Bean
RestTemplate restTemplate() {
return new RestTemplate();
}
public static void main(String[] args) {
SpringApplication.run(CustomerApplication.class, args);
logger.info("customer start success!");
}
}
3.bootstap.yml
#http端口配置
server:
port: 8001
connection-timeout: 5000
tomcat:
max-http-post-size: -1
max-threads: 1000
max-connections: 1000
# Mybatis配置
mybatis:
mapperLocations: classpath:mapper/*.xml
spring:
application:
name: soft-customer
cloud:
config:
name: soft-customer #文件前缀名称
uri: http://10.45.92.98:9002/
profile: dev
management:
security:
enabled: false
endpoints:
refresh:
enabled: true
# eureka注册中心配置
eureka:
client:
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:9001/eureka/
instance:
instance-id: ${spring.cloud.client.ip-address}:${server.port}
prefer-ip-address: true
hostname: ${spring.cloud.client.ip-address}
4.soft-customer-dev.yml
spring:
redis:
pool:
max-active: -1
max-wait: -1
max-idle: 8
min-idle: 0
timeout: 0
datasource:
type: ${datasource.db1.type}
driverClassName: ${datasource.db1.driver-class-name}
url: jdbc:mysql://${datasource.db1.ip}:${datasource.db1.port}/policy${datasource.db1.conn-params}
username: ${datasource.db1.username}
password: ${datasource.db1.password}
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 60000
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
druid:
filter:
config:
enabled: true
connection-properties: config.decrypt=${datasource.db1.decrypt};config.decrypt.key=${datasource.db1.decrypt-key}
myprops:
# 短信过期时间
smsExpTime: 300
#app微信登录地址
appWxUrl: https://api.weixin.qq.com/sns
#app微信登录appId
appId: wxa4409cfc1b2b44ee
#app微信登录appSecret
appSecret: 77965fcde9516e2dce760d944b9cd725
#验证码开关 1开 0关
mark: 1
#钉钉登录地址
dingUrl: https://oapi.dingtalk.com/sns/getuserinfo_bycode
#钉钉登录appId
dingAppId: dingoa4fq68g9fcfx6mqrs
#钉钉登录Secret
dingAppSecret: kc2CeRb7nywd7SXZ96-llQDFzjbXOL8umUUtmhgAmvxGVt70LWF69R4W5G8FnoSO
#苹果登录地址
appleUrl: https://appleid.apple.com
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
(完整版)基于SpringCloud微服务系统设计方案.pdf(完整版)基于SpringCloud微服务系统设计方案.pdf(完整版)基于SpringCloud微服务系统设计方案.pdf(完整版)基于SpringCloud微服务系统设计方案.pdf(完整版)基于Spring...
(完整版)基于SpringCloud微服务系统设计方案.docx(完整版)基于SpringCloud微服务系统设计方案.docx(完整版)基于SpringCloud微服务系统设计方案.docx(完整版)基于SpringCloud微服务系统设计方案.docx(完整版)基于...
Spring Cloud微服务⾯试题 1. Spring Cloud Netflix 和 Spring Cloud Alibaba 包括哪些组件 2. Nacos是CP还是AP? 3. Nacos作为注册中⼼应该选择是CP还是AP? 4. Nacos如何实现就近访问? 5. Nacos底层负载均衡...
Spring Cloud 微服务权限系统搭建教程 脚手架
springcloud 微服务 springcloud 微服务 springcloud 微服务 springcloud 微服务
Spring Cloud微服务实践.pdf
SpringCloud微服务分布式架构开发实战-50000-05-作业及参考答案.rar.
spring cloud 微服务helloworld项目,适合新手,项目基于spring cloud 微服务技术,使用了eureka注册公司,configserver配置中心,项目需要在本地新建配置中心配置文件
给大家分享一套课程——Spring Cloud微服务安全实战 中小企业可落地的完整安全方案,完整版,附源码。 采用流行的微服务架构开发时,有三大问题:认证授权、可用性、可视化需要面对。本课程从简单的API安全入手,...
《Spring Cloud 微服务全栈技术与案例解析》有目录,高清
SpringCloud微服务思维导图,系统的介绍了微服务中得几大组件,很详细
SpringCloud微服务基础 微服务开发入门很好的教程 SpringCloud微服务基础 微服务开发入门很好的教程
若依SpringCloud微服务版教程安装运行 0基础微服务架构能看懂的文章 附带有各个需要安装包,文档教程,代码地址和源代码 可私信提供哦
springcloud 微服务(全套视频)
使用visio手绘的 Spring Cloud 微服务框架,包含路由、服务注册、服务交互、配置管理
springcloud 微服务视频资料,很给力的,全网最火爆的视频资料。
Spring Cloud微服务架构实战[视频课程].txt打包整理.zip
Spring Cloud 微服务开发核心工具集。基础工具类、验证码、http、redis、ip2region、xss 等组件开箱即用。 Spring Cloud 微服务开发核心工具集。基础工具类、验证码、http、redis、ip2region、xss 等组件开箱即用。...
SpringCloud微服务架构笔记(一)