Commit 99e85ca5 authored by lilingmc's avatar lilingmc

add code

parents
Pipeline #174511 passed with stage
in 15 seconds
sonarqube_feature_preview:
script:
- git config --global user.email "sonar@duiba"
- git config --global user.name "sonar"
- gradle clean
- export
- gradle sonarqube -Dsonar.host.url=http://sonar.dui88.com -Dsonar.branch=dummy -Dsonar.login=reporter -Dsonar.password=duiba123456 -Dsonar.analysis.mode=preview -Dsonar.gitlab.project_id=$CI_PROJECT_PATH -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -x test
stage: test
only:
- /^feature.*$/
tags:
- test
sonarqube_hotfix_preview:
script:
- git config --global user.email "sonar@duiba"
- git config --global user.name "sonar"
- gradle clean
- export
- gradle sonarqube -Dsonar.host.url=http://sonar.dui88.com -Dsonar.branch=dummy -Dsonar.login=reporter -Dsonar.password=duiba123456 -Dsonar.analysis.mode=preview -Dsonar.gitlab.project_id=$CI_PROJECT_PATH -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -x test
stage: test
only:
- /^(hotfix|release).*$/
tags:
- test
sonarqube_develop_preview:
script:
- git config --global user.email "sonar@duiba"
- git config --global user.name "sonar"
- git checkout origin/develop
- gradle clean
- gradle sonarqube -Dsonar.host.url=http://sonar.dui88.com -Dsonar.login=reporter -Dsonar.password=duiba123456 -x test
only:
- develop
tags:
- test
# readme
//sonarqube
apply plugin: 'org.sonarqube'
sonarqube {
properties {
property "sonar.projectName", "tests"
property "sonar.projectKey", "cn.com.duiba.tests"
property "sonar.host.url","http://sonar.dui88.com"
property "sonar.login","admin"
property "sonar.password","admin"
}
}
buildscript {
ext{
springBootVersion = "1.5.12.RELEASE"
}
repositories {
mavenLocal()
maven { url "http://nexus.dui88.com:8081/nexus/content/groups/public/" }
maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
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'
}
}
allprojects {
apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: "jacoco"
apply plugin: 'propdeps'
test{
ignoreFailures = true
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
group = 'cn.com.duia.tuia.test.manager'
version = '1.0.0'
}
configurations{
all*.exclude group: 'log4j'
all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
all*.exclude group: 'com.coreos', module: 'jetcd-core'
}
subprojects {
apply plugin: "io.spring.dependency-management"
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencyManagement {
dependencies {
imports {
mavenBom 'cn.com.duiba.boot:spring-boot-ext-dependencies:1.2.268'
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Edgware.SR2'
}
//swagger
dependency 'io.springfox:springfox-swagger2:2.2.2'
dependency 'io.springfox:springfox-swagger-ui:2.2.2'
dependency ('cn.com.duiba.boot:spring-boot-ext:1.2.277'){
exclude 'com.coreos:jetcd-core'
exclude 'cn.com.duiba.boot:spring-boot-ext-dependencies'
}
ext['hazelcast.version']='3.11'
dependency 'com.alibaba:fastjson:1.2.29'
dependency 'org.mybatis.spring.boot:mybatis-spring-boot-starter:1.1.1'
dependency 'commons-beanutils:commons-beanutils:1.8.3'
dependency 'commons-cli:commons-cli:1.2'
dependency 'commons-collections:commons-collections:3.2'
dependency 'commons-dbcp:commons-dbcp:1.4'
dependency 'org.apache.commons:commons-dbcp2:2.1.1'
dependency 'commons-io:commons-io:2.4'
dependency 'commons-lang:commons-lang:2.6'
dependency 'commons-pool:commons-pool:1.6'
dependency 'commons-logging:commons-logging:1.1.2'
dependency 'org.apache.commons:commons-collections4:4.1'
dependency 'org.apache.commons:commons-lang3:3.4'
dependency 'mysql:mysql-connector-java:5.1.34'
}
}
/*dependencies {
compile 'cn.com.duiba.boot:spring-boot-start-cat'
}*/
repositories {
mavenLocal()
mavenCentral()
maven { url "http://nexus.dui88.com:8081/nexus/content/groups/public/" }
maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
mavenCentral()
}
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 'notify client'
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 sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
task listJars(description: 'Display all compile jars.') << {
configurations.compile.each { File file -> println file.name }
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'eclipse'
apply plugin: 'idea'
jar {
baseName = 'duiba-module-reports'
version = '1.0'
archiveName = "duiba-module-reports.jar"
manifest { attributes 'Main-Class': 'cn.com.duia.tuia.test.manager.rpc.ApplicationRPC' }
}
description = 'client'
dependencies {
compile project(':core')
compile project(':dal')
//swagger
compile('io.springfox:springfox-swagger2')
compile('io.springfox:springfox-swagger-ui')
compile('org.springframework.boot:spring-boot-starter-web')
compile('cn.com.duiba.boot:spring-boot-starter-config')
compile('cn.com.duiba.boot:spring-boot-ext-api')
compile('cn.com.duiba.boot:spring-boot-ext')
compile("cn.com.duiba.boot:spring-boot-starter-velocity")
compile('cn.com.duiba.boot:spring-boot-starter-xss')
compile('cn.com.duiba.boot:spring-boot-starter-cat')
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.cloud:spring-cloud-starter-config'
compile 'org.springframework.cloud:spring-cloud-starter-eureka'
compile 'org.springframework.cloud:spring-cloud-starter-hystrix'
compile 'org.springframework.cloud:spring-cloud-starter-ribbon'
compile 'org.springframework.cloud:spring-cloud-starter-feign'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
}
install{
enabled = false
}
uploadArchives{
enabled = false
}
//task buildStatic(type: Exec) {
// workingDir "$projectDir/"
// if (System.getProperty('os.name').toLowerCase().contains('windows')) {
// commandLine 'cmd', '/c', '..\\buildStatic.bat'
// } else {
// commandLine 'sh', '-c', '../buildStatic.sh'
// }
//}
//
//jar.dependsOn buildStatic
//buildStatic.dependsOn processResources
package cn.com.duia.tuia.test.manager.rpc;
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.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker
//@EnableDuibaFeignClients(basePackages = { "cn.com.duia" })
@EnableFeignClients(basePackages = {"cn.com.duia"})
@ImportResource({ "classpath:/spring/spring.xml" })
@ComponentScan(basePackages = {"cn.com.duia"})
@EnableEurekaClient
public class ApplicationRPC {
public static void main(String[] args) {
SpringApplication sa = new SpringApplication(ApplicationRPC.class);
sa.run(args);
}
}
package cn.com.duia.tuia.test.manager.rpc.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 SwaggerConfigRPC {
@Value("${tuia.test.manager.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.duia"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("tuia-test-manager")
.description("tuia-test-manager")
.termsOfServiceUrl("")
.version("1.0")
.build();
}
}
package cn.com.duia.tuia.test.manager.rpc.controller;
import cn.com.duia.tuia.test.manager.common.entity.AppEntity;
import cn.com.duia.tuia.test.manager.core.rpcservice.RpcService;
import cn.com.duia.tuia.test.manager.core.service.AppService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@RestController
public class RpcController {
@Autowired
private AppService appService;
@Resource
private RpcService rpcService;
@ApiOperation(value = "第一个接口for rpc", httpMethod = "GET")
@RequestMapping(value = "/test/inforpc", method = RequestMethod.GET)
public String info(@RequestParam(value = "msg") String msg) {
return "welcome to demo-springbootrpc: " + msg;
}
@ApiOperation(value = "第一个接口", httpMethod = "GET")
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public List<AppEntity> hello(){
return appService.selectApps();
}
@RequestMapping(value = "/test/index")
public String index(@RequestParam(value = "msg") String msg) {
return rpcService.query(msg);
}
}
# tomcat
server.port=1114
server.tomcat.access-log-enabled=false
server.tomcat.uri-encoding=UTF-8
# logging
logging.path=${user.home}/logs/tuia-test-manager
# swagger
tuia.test.manager.swagger.enable=true
# feignлʽĬʹhessian2
duiba.feign.serialization=hessian2
spring.application.name=tuia-client-manager
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.duia" level="INFO"/>
<root level="WARN">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</included>
<?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"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<bean id="dataSourceParent1" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close" abstract="true">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="initialSize" value="3"/>
<property name="maxTotal" value="500"/>
<property name="minIdle" value="3"/>
<property name="maxIdle" value="5"/>
<property name="maxWaitMillis" value="30000"/>
<property name="removeAbandonedOnBorrow" value="true"/>
<!-- Timeout in seconds before an abandoned connection can be removed. Defaults to 300 seconds -->
<property name="removeAbandonedTimeout" value="60"/>
<property name="logAbandoned" value="true"/>
<property name="testOnBorrow" value="true"/>
<property name="timeBetweenEvictionRunsMillis" value="90000"/><!-- 多久testWhileIdle一次 -->
<property name="minEvictableIdleTimeMillis" value="600000"/><!-- 池中的连接空闲多久后被回收,默认值就是30分钟。 -->
<property name="validationQuery" value="SELECT 1"/>
<property name="testWhileIdle" value="true"/>
</bean>
<bean name="druidServiceDataSource" parent="dataSourceParent1">
<property name="url" value="jdbc:mysql://dev.config.duibar.com:3306/druid_quartz_statistics"></property>
<property name="username" value="dev"></property>
<property name="password" value="dev_fas015"></property>
</bean>
<bean id="druidServiceSqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg>
<bean class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 实例化sqlSessionFactory时需要使用上述配置好的数据源以及SQL映射文件 -->
<property name="dataSource" ref="druidServiceDataSource"/>
<property name="mapperLocations">
<array>
<value>classpath*:mybatis/druidservice/*.xml</value>
</array>
</property>
<property name="configLocation" value="classpath:mybatis/sqlMapConfig.xml"/>
<property name="typeAliasesPackage" value="cn.com.duia.tuia.test.manager.common.entity"/>
</bean>
</constructor-arg>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionTemplateBeanName" value="druidServiceSqlSessionTemplate"/>
<property name="basePackage" value="cn.com.duia.tuia.test.manager.dao"/>
</bean>
</beans>
\ No newline at end of file
group 'cn.com.duiba.reports'
version '1.0.0'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
package cn.com.duia.tuia.test.manager.common.entity;
public class AppEntity {
private Long id;
private String appName;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
}
description = 'core'
dependencies {
compile project(":dal")
compile project(':common')
compile('com.google.guava:guava')
compile('com.google.code.gson:gson')
compile('cn.com.duiba.boot:spring-boot-ext-api')
compile('cn.com.duiba.boot:spring-boot-ext')
compile('org.apache.commons:commons-dbcp2')
compile ('org.springframework.cloud:spring-cloud-starter-feign')
compile('mysql:mysql-connector-java')
testCompile group: 'junit', name: 'junit', version: '4.12'
}
uploadArchives{
enabled = false
}
package cn.com.duia.tuia.test.manager.core.rpcservice;
import cn.com.duia.tuia.test.manager.core.rpcservice.impl.RpcServiceImpl;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(value = "duiba-test-reports", fallback = RpcServiceImpl.class)
public interface RpcService {
/**
* 查询test
*
* @param msg
* @return
*/
@RequestMapping(value = "/test/inforpc", method = RequestMethod.GET)
String query(@RequestParam(value = "msg") String msg);
}
package cn.com.duia.tuia.test.manager.core.rpcservice.impl;
import cn.com.duia.tuia.test.manager.core.rpcservice.RpcService;
import org.springframework.stereotype.Service;
@Service
public class RpcServiceImpl implements RpcService {
/**
* 查询test
*
* @param msg
* @return
*/
@Override
public String query(String msg) {
return "error";
}
}
package cn.com.duia.tuia.test.manager.core.service;
import cn.com.duia.tuia.test.manager.common.entity.AppEntity;
import java.util.List;
public interface AppService {
List<AppEntity> selectApps();
}
package cn.com.duia.tuia.test.manager.core.service.impl;
import cn.com.duia.tuia.test.manager.common.entity.AppEntity;
import cn.com.duia.tuia.test.manager.core.service.AppService;
import cn.com.duia.tuia.test.manager.dao.druid.AppDao;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class AppServiceImpl implements AppService {
@Resource
private AppDao appDao;
@Override
public List<AppEntity> selectApps() {
return appDao.selectApp();
}
}
description = 'dal'
dependencies {
compile project(':common')
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter')
}
uploadArchives{
enabled = false
}
package cn.com.duia.tuia.test.manager.dao.druid;
import cn.com.duia.tuia.test.manager.common.entity.AppEntity;
import java.util.List;
public interface AppDao {
List<AppEntity> selectApp();
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.com.duia.tuia.test.manager.dao.druid.AppDao">
<select id="selectApp" resultType="cn.com.duia.tuia.test.manager.common.entity.AppEntity">
SELECT
app_id AS id,
slot_name AS appNames
FROM tb_slot
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>
<typeAliases>
</typeAliases>
</configuration>
rootProject.name = 'tuia-test-manager'
include 'web'
include 'core'
include 'common'
include 'dal'
include 'client'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'eclipse'
apply plugin: 'idea'
jar {
baseName = 'tests-manager'
version = ''
archiveName = "tests-manager.jar"
manifest { attributes 'Main-Class': 'cn.com.duia.tuia.test.manager.Application' }
}
description = 'web'
dependencies {
compile project(':core')
compile project(':dal')
//swagger
compile('io.springfox:springfox-swagger2')
compile('io.springfox:springfox-swagger-ui')
compile('org.springframework.boot:spring-boot-starter-web')
compile('cn.com.duiba.boot:spring-boot-starter-config')
compile('cn.com.duiba.boot:spring-boot-ext-api')
compile('cn.com.duiba.boot:spring-boot-ext')
compile("cn.com.duiba.boot:spring-boot-starter-velocity")
compile('cn.com.duiba.boot:spring-boot-starter-xss')
compile('cn.com.duiba.boot:spring-boot-starter-cat')
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.cloud:spring-cloud-starter-config'
compile 'org.springframework.cloud:spring-cloud-starter-eureka'
compile 'org.springframework.cloud:spring-cloud-starter-hystrix'
compile 'org.springframework.cloud:spring-cloud-starter-ribbon'
compile 'org.springframework.cloud:spring-cloud-starter-feign'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
}
install{
enabled = false
}
uploadArchives{
enabled = false
}
//task buildStatic(type: Exec) {
// workingDir "$projectDir/"
// if (System.getProperty('os.name').toLowerCase().contains('windows')) {
// commandLine 'cmd', '/c', '..\\buildStatic.bat'
// } else {
// commandLine 'sh', '-c', '../buildStatic.sh'
// }
//}
//
//jar.dependsOn buildStatic
//buildStatic.dependsOn processResources
package cn.com.duia.tuia.test.manager;
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;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker
//@EnableDuibaFeignClients(basePackages = { "cn.com.duia" })
@EnableFeignClients(basePackages = {"cn.com.duia"})
@ImportResource({ "classpath:/spring/spring.xml" })
@ComponentScan(basePackages = {"cn.com.duia"})
public class Application {
public static void main(String[] args) {
SpringApplication sa = new SpringApplication(Application.class);
sa.run(args);
}
}
package cn.com.duia.tuia.test.manager.clientController;
import cn.com.duia.tuia.test.manager.common.entity.AppEntity;
  • 🔽 Remove this unused import 'cn.com.duia.tuia.test.manager.common.entity.AppEntity'. 📘

Please register or sign in to reply
import cn.com.duia.tuia.test.manager.core.rpcservice.RpcService;
import cn.com.duia.tuia.test.manager.core.service.AppService;
  • 🔽 Remove this unused import 'cn.com.duia.tuia.test.manager.core.service.AppService'. 📘

Please register or sign in to reply
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
  • 🔽 Remove this unused import 'org.springframework.beans.factory.annotation.Autowired'. 📘

Please register or sign in to reply
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
  • 🔽 Remove this unused import 'java.util.List'. 📘

Please register or sign in to reply
@RestController
public class ClientController {
@Resource
private RpcService rpcService;
@ApiOperation(value = "第一个接口for rpc", httpMethod = "GET")
@RequestMapping(value = "/test/inforpc", method = RequestMethod.GET)
public String info(@RequestParam(value = "msg") String msg) {
return "welcome to demo-springbootrpc: " + msg;
}
@RequestMapping(value = "/test/index")
public String index(@RequestParam(value = "msg") String msg) {
return rpcService.query(msg);
}
}
package cn.com.duia.tuia.test.manager.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("${tuia.test.manager.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.duia"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("tuia-test-manager")
.description("tuia-test-manager")
.termsOfServiceUrl("")
.version("1.0")
.build();
}
}
package cn.com.duia.tuia.test.manager.controller;
import cn.com.duia.tuia.test.manager.common.entity.AppEntity;
import cn.com.duia.tuia.test.manager.core.service.AppService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class TestController {
@Autowired
private AppService appService;
@ApiOperation(value = "第一个接口", httpMethod = "GET")
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public List<AppEntity> hello(){
return appService.selectApps();
}
}
# tomcat
server.port=1114
server.tomcat.access-log-enabled=false
server.tomcat.uri-encoding=UTF-8
# logging
logging.path=${user.home}/logs/tuia-test-manager
# swagger
tuia.test.manager.swagger.enable=true
# feign的序列化方式默认使用hessian2
duiba.feign.serialization=hessian2
spring.application.name=tuia-test-manager
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.duia" level="INFO"/>
<root level="WARN">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</included>
<?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"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<bean id="dataSourceParent1" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close" abstract="true">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="initialSize" value="3"/>
<property name="maxTotal" value="500"/>
<property name="minIdle" value="3"/>
<property name="maxIdle" value="5"/>
<property name="maxWaitMillis" value="30000"/>
<property name="removeAbandonedOnBorrow" value="true"/>
<!-- Timeout in seconds before an abandoned connection can be removed. Defaults to 300 seconds -->
<property name="removeAbandonedTimeout" value="60"/>
<property name="logAbandoned" value="true"/>
<property name="testOnBorrow" value="true"/>
<property name="timeBetweenEvictionRunsMillis" value="90000"/><!-- 多久testWhileIdle一次 -->
<property name="minEvictableIdleTimeMillis" value="600000"/><!-- 池中的连接空闲多久后被回收,默认值就是30分钟。 -->
<property name="validationQuery" value="SELECT 1"/>
<property name="testWhileIdle" value="true"/>
</bean>
<bean name="druidServiceDataSource" parent="dataSourceParent1">
<property name="url" value="jdbc:mysql://dev.config.duibar.com:3306/druid_quartz_statistics"></property>
<property name="username" value="dev"></property>
<property name="password" value="dev_fas015"></property>
</bean>
<bean id="druidServiceSqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg>
<bean class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 实例化sqlSessionFactory时需要使用上述配置好的数据源以及SQL映射文件 -->
<property name="dataSource" ref="druidServiceDataSource"/>
<property name="mapperLocations">
<array>
<value>classpath*:mybatis/druidservice/*.xml</value>
</array>
</property>
<property name="configLocation" value="classpath:mybatis/sqlMapConfig.xml"/>
<property name="typeAliasesPackage" value="cn.com.duia.tuia.test.manager.common.entity"/>
</bean>
</constructor-arg>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionTemplateBeanName" value="druidServiceSqlSessionTemplate"/>
<property name="basePackage" value="cn.com.duia.tuia.test.manager.dao"/>
</bean>
</beans>
\ No newline at end of file
  • SonarQube analysis reported 4 issues

    • 🔽 4 minor

    Watch the comments in this conversation to review them.

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