Commit da5a1619 authored by 张征龙's avatar 张征龙

初始化项目导入

parents
.gradle
/build/
!gradle/wrapper/gradle-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
### IntelliJ IDEA ###
*/out/
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
# readme
description = 'miria-project-test'
apply plugin: 'org.sonarqube'
buildscript {
ext {
springBootVersion = '1.5.9.RELEASE'
}
repositories {
mavenLocal()
maven { url "http://nexus.dui88.com:8081/nexus/content/groups/public/" }
maven { url "https://plugins.gradle.org/m2/" } //sonarqube
maven { url 'http://repo.spring.io/plugins-release' }
mavenCentral()
}
dependencies {
classpath "io.spring.gradle:dependency-management-plugin:0.6.1.RELEASE"
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5' //sonarqube
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7'
}
}
apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
apply plugin: "io.spring.dependency-management"
apply plugin: 'org.springframework.boot'
apply plugin: 'propdeps'
test {
ignoreFailures = true
}
group = 'cn.com.duiba'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
jar {
baseName = 'miria-project-test'
version = ''
}
configurations {
all*.exclude group: 'log4j', module: 'log4j'
all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
all*.exclude group: 'javax.servlet', module: 'servlet-api' //servlet 2.5
}
repositories {
mavenLocal()
maven { url "http://nexus.dui88.com:8081/nexus/content/groups/public/" }
maven { url "https://plugins.gradle.org/m2/" } //sonarqube
maven { url 'http://repo.spring.io/plugins-release' }
mavenCentral()
}
dependencyManagement {
dependencies {
imports {
mavenBom 'cn.com.duiba.boot:spring-boot-ext-dependencies:1.2.112'
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Edgware.RELEASE'
}
}
}
dependencies {
compile 'cn.com.duiba.boot:spring-boot-starter-perftest'
compile 'cn.com.duiba.boot:spring-boot-starter-cat'
compile 'cn.com.duiba.boot:spring-boot-starter-xss'
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.boot:spring-boot-starter-freemarker'
compile 'org.springframework.cloud:spring-cloud-starter-config'
compile 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
compile 'org.springframework.cloud:spring-cloud-starter-netflix-hystrix'
compile 'org.springframework.cloud:spring-cloud-starter-netflix-ribbon'
compile 'org.springframework.cloud:spring-cloud-starter-openfeign'
compile 'javax.validation:validation-api:1.1.0.Final'
compile 'io.springfox:springfox-swagger-ui:2.5.0'
compile 'io.springfox:springfox-swagger2:2.5.0'
compile 'com.google.guava:guava:18.0'
compile 'com.alibaba:fastjson:1.2.29'
compile('org.projectlombok:lombok:1.16.18')
testCompile 'org.springframework.boot:spring-boot-starter-test'
}
install {//
enabled = false
}
uploadArchives {//
enabled = false
}
uploadArchives {
repositories {
mavenDeployer {
snapshotRepository(url: "http://nexus.dui88.com:8081/nexus/content/repositories/snapshots/") {
authentication(userName: "admin", password: "admin123")
}
repository(url: "http://nexus.dui88.com:8081/nexus/content/repositories/releases/") {
authentication(userName: "admin", password: "admin123")
}
pom.project {
name project.name
packaging 'jar'
description project.name
url 'www.duiba.com.cn'
scm {
url ''
connection ''
developerConnection ''
}
licenses {
license {
name 'No License'
url 'http://www.duiba.com.cn'
distribution 'repo'
}
}
developers {
developer {
id 'xuhengfei'
name 'Hengfei Xu'
}
}
}
}
}
}
task listJars(description: 'Display all compile jars.') << {
configurations.compile.each { File file -> println file.name }
}
rootProject.name = 'miria-project-test'
package cn.com.duiba.miria.project.test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableDuibaFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker
@EnableDuibaFeignClients(basePackages = { "cn.com.duiba" })
public class Application {
public static void main(String[] args) {
SpringApplication sa = new SpringApplication(Application.class);
sa.run(args);
}
}
package cn.com.duiba.miria.project.test.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Value("${miria.project.test.swagger.enable}")
private Boolean swaggerEnable;
/**
* swaggger配置方法
*/
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.enable(swaggerEnable)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("cn.com.duiba"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("miria-project-test")
.description("miria-project-test")
.termsOfServiceUrl("")
.version("1.0")
.build();
}
}
package cn.com.duiba.miria.project.test.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Slf4j
@Controller
@RequestMapping("/monitor")
public class MonitorController {
@RequestMapping(value = "check",method = RequestMethod.GET)
@ResponseBody
public String check(){
String res="ok";
return res;
}
@RequestMapping(value = "test",method = RequestMethod.GET)
@ResponseBody
public String test(){
String res="ok";
log.info("连接{}",res);
return res;
}
}
#tomcat
server.port=1112
server.tomcat.access-log-enabled=false
server.tomcat.uri-encoding=UTF-8
#logging
logging.path=${user.home}/logs/miria-project-test
#swagger
miria.project.test.swagger.enable=true
\ No newline at end of file
spring.application.name=miria-project-test
spring.cloud.config.uri=http://configserver.dui88.com
spring.cloud.config.fail-fast=true
spring.profiles.active=dev
spring.devtools.restart.enabled=true
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="logback/default.xml" />
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<included>
<property name="logpath" value="${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}"/>
<property name="logPattern" value="%d{HH:mm:ss.SSS} %-5level [%thread] %logger{32}[%file:%line] -&gt; %msg%n"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${logPattern}</pattern>
<charset class="java.nio.charset.Charset">utf8</charset>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${logpath}/application.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logpath}/application_%d{yyyy-MM-dd}.log</FileNamePattern>
<maxHistory>10</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${logPattern}</pattern>
</encoder>
</appender>
<!-- 需要记录日志的包 -->
<logger name="cn.com.duiba" level="INFO"/>
<logger name="cn.com.duiba" level="INFO"/>
<root level="WARN">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</included>
package cn.com.duiba.miria.project.test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = Application.class)
@AutoConfigureMockMvc
public abstract class BaseTest {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment