/*
* Copyright 2007-present the original author or authors.
*
* Licensed 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.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* 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/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".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 directory '" + 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 {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
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 @ConfigurationProperties使用详解(源代码)
共262个文件
xml:210个
java:12个
properties:8个
5星 · 超过95%的资源 需积分: 24 0 下载量 189 浏览量
2023-01-28
15:05:54
上传
评论
收藏 320KB ZIP 举报
温馨提示
1.1 简述 在Spring Boot中注解@ConfigurationProperties有三种使用场景,而通常情况下我们使用的最多的只是其中的一种场景。本篇文章带大家了解一下三种场景的使用情况。 1.2 场景一 使用@ConfigurationProperties和@Component注解到bean定义类上,这里@Component代指同一类实例化Bean的注解。 1.3 场景二 使用@ConfigurationProperties和@Bean注解在配置类的Bean定义方法上。以数据源配置为例: 使用@ConfigurationProperties注解到普通类,然后再通过@EnableConfigurationPropertiesz注解到启动类中定义为Bean。 这里User对象并没有使用@Component相关注解。 @EnableConfigurationProperties 关于@EnableConfigurationProperties注解的使用: @EnableConfigurationProperties的作用是把springboot配置文件中的值与我们的xxxPr
资源推荐
资源详情
资源评论
收起资源包目录
SpringBoot @ConfigurationProperties使用详解(源代码) (262个子文件)
User.class 2KB
User.class 2KB
AtConfigurationpropertiesAnno03ApplicationTests.class 985B
AtConfigurationpropertiesAnnoApplicationTests.class 969B
AtConfigurationpropertiesAnno03Application.class 880B
AtConfigurationpropertiesAnnoApplication.class 870B
mvnw.cmd 6KB
mvnw.cmd 6KB
mvnw.cmd 6KB
.gitignore 336B
.gitignore 336B
.gitignore 333B
.gitignore 333B
.gitignore 333B
.gitignore 302B
at_configurationproperties_anno02.iml 8KB
at_configurationproperties_anno01.iml 8KB
at_configurationproperties_anno03.iml 8KB
maven-wrapper.jar 50KB
maven-wrapper.jar 50KB
maven-wrapper.jar 50KB
MavenWrapperDownloader.java 5KB
MavenWrapperDownloader.java 5KB
MavenWrapperDownloader.java 5KB
User.java 844B
DataSourceConfig.java 682B
AtConfigurationpropertiesAnno03Application.java 603B
AtConfigurationpropertiesAnno03ApplicationTests.java 481B
AtConfigurationpropertiesAnnoApplicationTests.java 475B
AtConfigurationpropertiesAnno02Application.java 404B
AtConfigurationpropertiesAnnoApplication.java 398B
User.java 332B
AtConfigurationpropertiesAnno02ApplicationTests.java 275B
spring-configuration-metadata.json 415B
spring-configuration-metadata.json 409B
HELP.md 993B
HELP.md 993B
HELP.md 993B
README.md 169B
README.md 144B
README.md 32B
mvnw 10KB
mvnw 10KB
mvnw 10KB
application.properties 349B
maven-wrapper.properties 218B
maven-wrapper.properties 218B
maven-wrapper.properties 218B
application.properties 143B
application.properties 143B
application.properties 141B
application.properties 141B
workspace.xml 6KB
workspace.xml 5KB
workspace.xml 3KB
pom.xml 2KB
pom.xml 2KB
pom.xml 2KB
compiler.xml 954B
compiler.xml 954B
compiler.xml 890B
jarRepositories.xml 864B
jarRepositories.xml 864B
jarRepositories.xml 864B
Maven__org_springframework_boot_spring_boot_configuration_processor_2_6_11.xml 779B
Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_13_3.xml 760B
Maven__org_springframework_boot_spring_boot_configuration_processor_2_6_11.xml 755B
Maven__org_springframework_boot_spring_boot_configuration_processor_2_6_11.xml 755B
Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_6_11.xml 744B
Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_13_3.xml 736B
Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_13_3.xml 736B
Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml 724B
Maven__org_springframework_boot_spring_boot_starter_logging_2_6_11.xml 723B
Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_6_11.xml 720B
Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_6_11.xml 720B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_13_3.xml 719B
Maven__org_springframework_boot_spring_boot_starter_tomcat_2_6_11.xml 716B
Maven__org_springframework_boot_spring_boot_autoconfigure_2_6_11.xml 709B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_13_3.xml 705B
Maven__org_springframework_boot_spring_boot_starter_json_2_6_11.xml 702B
Maven__org_springframework_boot_spring_boot_starter_test_2_6_11.xml 702B
Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml 700B
Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml 700B
Maven__org_springframework_boot_spring_boot_starter_logging_2_6_11.xml 699B
Maven__org_springframework_boot_spring_boot_starter_logging_2_6_11.xml 699B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_13_3.xml 695B
Maven__org_springframework_boot_spring_boot_starter_web_2_6_11.xml 695B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_13_3.xml 695B
Maven__org_springframework_boot_spring_boot_starter_tomcat_2_6_11.xml 692B
Maven__org_springframework_boot_spring_boot_starter_tomcat_2_6_11.xml 692B
Maven__org_springframework_boot_spring_boot_autoconfigure_2_6_11.xml 685B
Maven__org_springframework_boot_spring_boot_autoconfigure_2_6_11.xml 685B
Maven__org_apache_tomcat_embed_tomcat_embed_websocket_9_0_65.xml 684B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_13_3.xml 681B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_13_3.xml 681B
Maven__org_springframework_boot_spring_boot_starter_json_2_6_11.xml 678B
Maven__org_springframework_boot_spring_boot_starter_test_2_6_11.xml 678B
Maven__org_springframework_boot_spring_boot_starter_json_2_6_11.xml 678B
Maven__org_springframework_boot_spring_boot_starter_test_2_6_11.xml 678B
Maven__com_fasterxml_jackson_core_jackson_annotations_2_13_3.xml 675B
共 262 条
- 1
- 2
- 3
FBIHackerHarry浩
- 粉丝: 3w+
- 资源: 60
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 通道处理过程的模拟通常涉及对通道处理机制的理解与实现.txt
- Flume进阶-自定义拦截器jar包
- Dubins曲线算法讲解和在运动规划中的使用.pdf
- 上市公司-股票性质数据-工具变量(民企、国企、央企)2003-2022年.dta
- 上市公司-股票性质数据-工具变量(民企、国企、央企)2003-2022年.xlsx
- Reeds+Shepp曲线算法讲解和实现.pdf
- 毕业设计基于SpringBoot+MyBatisPlus+MySQL+Vue的外卖配送信息系统源代码+数据库
- 词向量(Word Embeddings)是自然语言处理(NLP)领域的一种重要技术.txt
- Surfer,线性函数
- MyBatis 的动态 SQL 是其核心特性之一.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页