Commit 60d41cfd authored by liling's avatar liling

add code

parents
Pipeline #176612 failed with stages
in 0 seconds
File added
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
//sonarqube
apply plugin: 'org.sonarqube'
sonarqube {
properties {
property "sonar.projectName", "dmp"
property "sonar.projectKey", "cn.com.duiba.dmp"
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.dmp'
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 }
}
}
description = 'dmp-client'
dependencies {
compile project(':dmp-common')
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter')
}
uploadArchives{
enabled = false
}
\ No newline at end of file
package cn.com.duia.dmp.client;
public class a {
}
package cn.com.duia.dmp.client.remoteservice;
public interface RemoteDMPService {
}
description = 'dmp-common'
apply plugin: 'maven'
jar {
manifest{
attributes 'Implementation-Title':'REPORTS', 'Implementation-Version': version
}
}
dependencies {
//swagger
compile('io.springfox:springfox-swagger2')
compile('io.springfox:springfox-swagger-ui')
testCompile group: 'junit', name: 'junit', version: '4.12'
}
package cn.com.duia.dmp.common.entity;
public class AppEntity {
private String appName;
private Long appId;
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public Long getAppId() {
return appId;
}
public void setAppId(Long appId) {
this.appId = appId;
}
}
description = 'dmp-core'
dependencies {
compile project(":dmp-dal")
compile project(':dmp-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('mysql:mysql-connector-java')
testCompile group: 'junit', name: 'junit', version: '4.12'
}
uploadArchives{
enabled = false
}
package cn.com.duia.dmp.core;
public class a {
}
package cn.com.duia.dmp.core.service;
import cn.com.duia.dmp.common.entity.AppEntity;
import java.util.List;
public interface AppService {
List<AppEntity> selectApp();
}
package cn.com.duia.dmp.core.service.impl;
import cn.com.duia.dmp.common.entity.AppEntity;
import cn.com.duia.dmp.core.service.AppService;
import cn.com.duiba.dmp.dal.mapper.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> selectApp() {
return appDao.selectApp();
}
}
description = 'dmp-dal'
dependencies {
compile project(':dmp-common')
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter')
}
uploadArchives{
enabled = false
}
\ No newline at end of file
package cn.com.duiba.dmp.dal.mapper.druid;
import cn.com.duia.dmp.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.duiba.dmp.dal.mapper.druid.AppDao">
<select id="selectApp" resultType="cn.com.duia.dmp.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>
group 'cn.com.duia'
version '0.0.1-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'eclipse'
apply plugin: 'idea'
jar {
baseName = 'dmp'
version = '1.0.0'
archiveName = "dmp.jar"
manifest { attributes 'Main-Class': 'cn.com.duia.dmp.Application' }
}
description = 'web'
dependencies {
compile project(':dmp-core')
compile project(':dmp-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.dmp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableDuibaFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
//@EnableSwagger2
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
@ImportResource({ "classpath:/spring/spring.xml" })
@EnableDiscoveryClient
@EnableCircuitBreaker
@EnableDuibaFeignClients(basePackages = { "cn.com.duia" })
@ComponentScan(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.duia.dmp.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("${dmp.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("dmp")
.description("dmp")
.termsOfServiceUrl("")
.version("1.0")
.build();
}
}
package cn.com.duia.dmp.controller;
import cn.com.duia.dmp.common.entity.AppEntity;
import cn.com.duia.dmp.core.service.AppService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@RestController
public class TestController {
//@Resource
//private AppService appService;
// @ApiOperation(value = "第一个接口", httpMethod = "GET")
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public List<AppEntity> hello(){
return new ArrayList<>();
//return appService.selectApp();
}
}
# tomcat
server.port=1112
server.tomcat.access-log-enabled=false
server.tomcat.uri-encoding=UTF-8
# logging
logging.path=${user.home}/logs/dmp
# swagger
dmp.swagger.enable=true
# feign的序列化方式默认使用hessian2
duiba.feign.serialization=hessian2
spring.application.name=dmp
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/druid/*.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.duiba.dmp.dal.mapper.druid"/>
</bean>
</beans>
\ No newline at end of file
rootProject.name = 'dmp'
include 'dmp-web'
include 'dmp-core'
include 'dmp-dal'
include 'dmp-common'
include 'dmp-client'
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