/opt/nexus/
目錄作爲nexus的根目錄,把nexus-2.14.5-02-bundle.tar.gz
解壓到此目錄中/opt/nexus/nexus-2.14.5-02/conf/nexus.properties
文件,把application-port
設置成合適的端口/opt/nexus/nexus-2.14.5-02/bin/jsw/conf/wrapper.conf
文件,配置合適的JVM參數.3.1在文件的最開始添加java
#@wjw_add wrapper.ignore_sequence_gaps=TRUE
3.2添加JVM參數git
#->@wjw_add wrapper.java.additional.11=-Djava.net.preferIPv4Stack=true wrapper.java.additional.12=-Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl" wrapper.java.additional.13=-server wrapper.java.additional.14=-Xms1g wrapper.java.additional.15=-Xmx8g wrapper.java.additional.16=-XX:ReservedCodeCacheSize=96m #<-@wjw_add
3.3註釋掉github
#@wjw_note wrapper.java.initmemory=256 #@wjw_note wrapper.java.maxmemory=768
/opt/nexus/nexus-2.14.5-02/bin/nexus
文件,去掉RUN_AS_USER
的註釋,改爲RUN_AS_USER=root
nexus
,/opt/nexus/nexus-2.14.5-02/bin/nexus start
Gradle
環境Linux:web
- 建立
/opt/GRADLE_USER_HOME
目錄- 修改
/etc/profile
,在最後添加export > GRADLE_USER_HOME=/opt/GRADLE_USER_HOME
- 執行
source /etc/profile
,是配置環境生效
Windows:spring
打開
系統屬性->環境變量->添加用戶變量
apache
變量名: GRADLE_USER_HOME 變量值: z:\GRADLE_USER_HOME
Gradle Wrapper
引用本地的發佈包Gradle Wrapper 免去了用戶在使用 Gradle 進行項目構建時須要安裝 Gradle 的繁瑣步驟. 每一個 Gradle Wrapper 都綁定到一個特定版本的 Gradle,因此當你第一次在給定 Gradle 版本下運行上面的命令之一時,它將下載相應的 Gradle 發佈包,並使用它來執行構建.默認,Gradle Wrapper 的發佈包是指向的官網的 Web 服務地址,有時候,下載這個發佈包比較慢甚至不成功,本文演示了加速下載發佈包的方式.api
Gradle Wrapper 的配置在gradle/wrapper/gradle-wrapper.properties
, 其默認的配置以下:app
distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
其中,distributionUrl 指 明瞭 Gradle Wrapper 下載 Gradle 發佈包的位置.若是遇到下載這個發佈包比較慢甚至不成功的時候,能夠將該地址引到本地的文件,好比:eclipse
#distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip distributionUrl=file\:/D:/software/webdev/java/gradle-3.5-all.zip
這樣構建的速度將會很是快了.固然,前提是,要實現準本好發佈包放到本地.jvm
build.gradle
文件模版buildscript { ext { springBootVersion = '1.5.8.RELEASE' } repositories { mavenLocal() maven{ url "http://SVN:8081/nexus/content/groups/public"} mavenCentral() jcenter() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' group = 'org.wjw.EurekaServer' version = '1.0.0' sourceCompatibility = 1.8 targetCompatibility = 1.8 [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8' repositories { mavenLocal() maven{ url "http://SVN:8081/nexus/content/groups/public"} mavenCentral() jcenter() } ext { springCloudVersion = 'Dalston.SR4' } dependencies { compile('org.springframework.cloud:spring-cloud-starter-eureka-server') { exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' } compile('org.slf4j:slf4j-api') compile('org.slf4j:slf4j-log4j12') compile('commons-logging:commons-logging') compile('org.springframework.boot:spring-boot-starter-actuator') { exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' } compile('org.springframework.boot:spring-boot-starter-security') { exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' } testCompile('org.springframework.boot:spring-boot-starter-test') } dependencyManagement { imports { mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" } } //bootRun { // args = ["--spring.profiles.active=test"] //} //@wjw_note 添加接受JVM命令行參數,例如:-PjvmArgs="-XX:ReservedCodeCacheSize=96m -Xmx1g" //@wjw_note 添加接受project命令行參數,例如:-PappArgs="--spring.profiles.active=dev" bootRun { if ( project.hasProperty('jvmArgs') ) { jvmArgs = (project.jvmArgs.split("\\s+") as List) } if(project.hasProperty("appArgs")){ args(appArgs) println "Task args:"+args } }
build.gradle
文件模版apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'maven' group = 'org.wjw.cloud.config' version = '1.0.0' sourceCompatibility = 1.6 targetCompatibility = 1.6 [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8' repositories { mavenLocal() maven{ url "http://SVN:8081/nexus/content/groups/public"} mavenCentral() jcenter() } dependencies { compile('io.github.openfeign:feign-core:9.5.0') compile('io.github.openfeign:feign-ribbon:9.5.0') testCompile('junit:junit:4.12') } jar.doFirst { manifest { def manifestFile = "${projectDir}/META-INF/MANIFEST.MF" if ( new File( manifestFile ).exists() ) { from ( manifestFile ) } def requiredProjects = '' configurations.compile.getAllDependencies().withType(ProjectDependency).each {dep-> def dependantProjects = dep.getDependencyProject() def projects = project(dependantProjects.path).libsDir.list().findAll{it.endsWith('.jar')} projects.removeAll(projects.findAll{it.endsWith('test.jar')}) def requiredProject = projects.join(' ') requiredProjects += requiredProject.replaceAll(/ /,'%20') + ' ' logger.info 'Required Project: ' + requiredProject } logger.info 'Required requiredProjects: ' + requiredProjects def compileFiles = configurations.compile.files{ it instanceof ExternalDependency }.collect { File file = it "${file.name}" }.join(' ') def manifestPath = requiredProjects + compileFiles logger.info 'Manifest: '+ manifestPath attributes 'Dependency-Libs': manifestPath attributes 'Build-Date': new Date(); attributes 'Implementation-Title': project.name attributes 'Application-Version': project.version } } uploadArchives { repositories.mavenDeployer { repository(url: "http://svn:8081/nexus/content/repositories/thirdparty/") { authentication(userName: "wangjunwei", password: "xxxxxx") } pom.groupId = "${project.group}" pom.artifactId = "${project.name}" pom.version = "${project.version}" pom.project { name project.name packaging 'jar' description '封裝了spring cloud config server,能夠很簡單的獲取配置信息!' licenses { license { name 'The Apache Software License, Version 2.0' url 'http://www.apache.org/licenses/LICENSE-2.0.txt' distribution '封裝了spring cloud config server,能夠很簡單的獲取配置信息!' } } developers { developer { id 'wangjunwei' name 'Wang JunWei' } } } } } //爲項目生成**.jar/**-javadoc.jar/**-sources.jar task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from 'build/docs/javadoc' } task sourcesJar(type: Jar) { classifier = 'sources' from sourceSets.main.allSource } artifacts { archives jar archives javadocJar archives sourcesJar }
project.name
在項目目錄下建立settings.gradle
,文件類容是
//By default, Gradle uses the directory name as project name. //You can change this by creating a settings.gradle file in the directory which specifies the project name. rootProject.name ='org.wjw.cloud.CloudConfigService'