/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.Properties;
public class MavenWrapperDownloader {
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL =
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: : " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
springboot 实现mysql读写分离 通过aop 并且根据方法名进行分类 实现读写分离 (116个子文件)
DataSourceAop.class 2KB
DataSourceConfig.class 2KB
DBContextHolder.class 2KB
MyBatisConfig.class 2KB
RWController.class 1KB
UserService.class 1KB
User.class 1KB
DBTypeEnum.class 1KB
MasterApplication.class 809B
MyRoutingDataSource.class 682B
MasterApplicationTests.class 533B
UserDao.class 356B
Master.class 164B
mvnw.cmd 6KB
.gitignore 303B
master.iml 8KB
maven-wrapper.jar 47KB
MavenWrapperDownloader.java 5KB
DataSourceAop.java 2KB
DataSourceConfig.java 2KB
MyBatisConfig.java 2KB
DBContextHolder.java 1KB
RWController.java 930B
UserService.java 738B
User.java 686B
MasterApplication.java 510B
MyRoutingDataSource.java 406B
UserDao.java 346B
MasterApplicationTests.java 274B
DBTypeEnum.java 133B
Master.java 119B
HELP.md 517B
mvnw 9KB
maven-wrapper.properties 116B
application1.properties 17B
application1.properties 17B
workspace.xml 74KB
uiDesigner.xml 9KB
pom.xml 2KB
UserDao.xml 831B
UserDao.xml 831B
Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_1_3_RELEASE.xml 769B
Maven__org_springframework_boot_spring_boot_starter_logging_2_1_3_RELEASE.xml 748B
Maven__org_springframework_boot_spring_boot_starter_tomcat_2_1_3_RELEASE.xml 741B
Maven__org_springframework_boot_spring_boot_autoconfigure_2_1_3_RELEASE.xml 734B
Maven__org_mybatis_spring_boot_mybatis_spring_boot_autoconfigure_2_0_0.xml 730B
Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_8.xml 729B
Maven__org_springframework_boot_spring_boot_starter_json_2_1_3_RELEASE.xml 727B
Maven__org_springframework_boot_spring_boot_starter_jdbc_2_1_3_RELEASE.xml 727B
Maven__org_springframework_boot_spring_boot_starter_test_2_1_3_RELEASE.xml 727B
Maven__org_springframework_boot_spring_boot_starter_aop_2_1_3_RELEASE.xml 720B
Maven__org_springframework_boot_spring_boot_starter_web_2_1_3_RELEASE.xml 720B
Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml 700B
Maven__org_springframework_boot_spring_boot_starter_2_1_3_RELEASE.xml 692B
Maven__org_mybatis_spring_boot_mybatis_spring_boot_starter_2_0_0.xml 688B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_8.xml 688B
Maven__org_hibernate_validator_hibernate_validator_6_0_14_Final.xml 681B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_8.xml 674B
Maven__org_springframework_boot_spring_boot_test_2_1_3_RELEASE.xml 671B
Maven__org_apache_tomcat_embed_tomcat_embed_websocket_9_0_16.xml 660B
Maven__org_springframework_spring_expression_5_1_5_RELEASE.xml 658B
Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml 644B
Maven__org_springframework_spring_context_5_1_5_RELEASE.xml 637B
Maven__org_springframework_boot_spring_boot_2_1_3_RELEASE.xml 636B
Maven__org_springframework_spring_webmvc_5_1_5_RELEASE.xml 630B
Maven__org_apache_tomcat_embed_tomcat_embed_core_9_0_16.xml 625B
compiler.xml 624B
Maven__com_fasterxml_jackson_core_jackson_databind_2_9_8.xml 623B
Maven__org_springframework_spring_beans_5_1_5_RELEASE.xml 623B
Maven__org_springframework_spring_jdbc_5_1_5_RELEASE.xml 616B
Maven__org_springframework_spring_test_5_1_5_RELEASE.xml 616B
Maven__org_springframework_spring_core_5_1_5_RELEASE.xml 616B
Maven__javax_annotation_javax_annotation_api_1_3_2.xml 611B
Maven__javax_validation_validation_api_2_0_1_Final.xml 611B
Maven__org_apache_tomcat_embed_tomcat_embed_el_9_0_16.xml 611B
Maven__org_springframework_spring_web_5_1_5_RELEASE.xml 609B
Maven__org_springframework_spring_aop_5_1_5_RELEASE.xml 609B
Maven__org_springframework_spring_jcl_5_1_5_RELEASE.xml 609B
Maven__org_apache_logging_log4j_log4j_to_slf4j_2_11_2.xml 608B
Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml 608B
Maven__org_springframework_spring_tx_5_1_5_RELEASE.xml 602B
Maven__com_fasterxml_jackson_core_jackson_core_2_9_8.xml 595B
Maven__net_bytebuddy_byte_buddy_agent_1_9_10.xml 578B
Maven__mysql_mysql_connector_java_8_0_15.xml 574B
Maven__org_apache_logging_log4j_log4j_api_2_11_2.xml 573B
misc.xml 569B
Maven__ch_qos_logback_logback_classic_1_2_3.xml 568B
Maven__org_apache_commons_commons_lang3_3_8.xml 556B
Maven__org_hamcrest_hamcrest_library_1_3.xml 553B
Maven__org_mybatis_mybatis_spring_2_0_0.xml 549B
Maven__ch_qos_logback_logback_core_1_2_3.xml 547B
Maven__com_jayway_jsonpath_json_path_2_4_0.xml 546B
Maven__org_assertj_assertj_core_3_11_1.xml 542B
Maven__org_mockito_mockito_core_2_23_4.xml 542B
Maven__net_minidev_accessors_smart_1_2.xml 542B
Maven__org_aspectj_aspectjweaver_1_9_2.xml 542B
Maven__org_skyscreamer_jsonassert_1_5_0.xml 537B
Maven__net_bytebuddy_byte_buddy_1_9_10.xml 536B
Maven__org_xmlunit_xmlunit_core_2_6_2.xml 535B
Maven__org_slf4j_jul_to_slf4j_1_7_25.xml 534B
共 116 条
- 1
- 2
资源评论
CSDN万里无云万里天
- 粉丝: 10
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功