springBoot 项目自定义命名application.properties配置文件名称

使用JDBC连接数据库(二)(配置文件) 利用db.properties配置文件形式连接数据库 一、JDBC连接数据库准备工作: 1.工程结构: 2.数据库建表: create table user( id int auto_increment primary key, username varchar(50), password varchar(50) ); insert into user(username,pas... 阅读详情

最近因项目原因,需要将springboot项目的properties文件改为自定义名称,在查看一些资料后最终解决,特记录一下!
参考资料:https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config-application-property-files

为方便期间,更改名称后的properties文件仍然放置在resource下(相当于classpa:/ 在classpath的根目录下)即可;
在这里插入图片描述

解决方法

  1. 解决方法一:
    将更改properties文件名的项目使用Maven工具打成JAR包,然后在DOS命令行启动项目:

    java -jar myDemo.jar --spring.config.name=config_demo

  2. 仍然是以JAR的形式来启动项目,在项目启动前设置好环境变量;

    set SPRING_CONFIG_NAME=config_demo
    java -jar myDemo.jar

  3. 上面两种方法需要在项目启动命令中更改环境变量,比较麻烦。下面介绍最实用的使用更改代码的方式来实现,使得springboot项目启动加载时默认去读取更改名称后的properties文件:
    通过SpringApplicationBuilder类的properties(String… defaultProperties)方法来实现,代码如下:
@SpringBootApplication
public class DemoSpringbootApplication {
   public static void main(String[] args) {
       new SpringApplicationBuilder(DemoApplication.class)
               .properties("spring.config.name:config_demo")
               .build()
               .run(args);
   }
}
SpringBoot配置文件application.properties核心配置详解与生产环境实战指南 在Java应用开发中,配置文件是连接代码与运行时环境的关键桥梁,它定义了应用的行为、资源连接和性能参数。其核心原理在于实现配置的外部化与环境的隔离,通过键值对或层级结构管理属性。这一机制的技术价值在于提升了应用的可维护性、可移植性和安全性,使得同一份代码能够轻松适应开发、测试、生产等不同场景。在SpringBoot框架中,application.properties(或application.yml)作为“约定大于配置”理念的核心载体,扮演着项目神经中枢的角色。它集中管理了服务器端口、数据库连接池、日志级别 阅读详情

相关推荐

2025海外代理IP深度横评:Bright Data、IPFoxy、SmartProxy等六大服务商实战对比

本文深度横评2025年六大海外代理IP服务商(Bright Data、IPFoxy、SmartProxy、IPIPGO、Kookeey及青果网络),基于实战测试数据,从IP池质量、速度稳定性、性价比等维度进行对比。针对跨境电商、数据爬虫、社交媒体管理等不同业务场景,提供精准的选购指南与避坑建议,帮助企业用户根据自身需求选择最合适的代理IP解决方案。

weixin_29196891的博客 434

springboot的配置文件名称可以改嘛,咋改

这里写目录标题1 springboot的配置文件名称可以改嘛,咋改 1 springboot的配置文件名称可以改嘛,咋改 可以改,我们不想要application.yml默认的名字,或者在不同的环境下,依赖的外部资源是不一样的。比如,在windows上开发,在linux下进行测试时,无法将开发环境和测试i环境构造成一致的。 此时,就需要两个配置文件来解决此事。开发环境一个配置文件,测试环境一个配置文件。 我们写3个配置文件 3个配置文件的端口是不一样的,我们就改变配置文件名称,看看启动的时候会使用哪个端

一天不写代码难受的博客 3584

深入构建加密货币价格预测系统:从数据获取到模型优化的完整指南!

🏆本文收录于「编程与技术实战」专栏,此专栏涵盖了C/C++编程、人工智能、数据结构、机器学习等技术领域的内容,助你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!!

**My Coding Family** 1276

springBoot自定义application.properties配置文件名称

将springboot项目的properties文件改为自定义名称 两个方法

橘足轻重的博客 1326

VS2017中调用gdal(C#版)的方法二(含gdal下载地址,配置过程,代码测试,超详细!!)

VS2017中gdal(C#)版的配置与测试 上次记录了直接在VS2017中下载并应用gdal的方法,这次来记录一下网上下载的安装包配置与测试的方法。 一、环境、版本及下载地址 win10,vs2017社区版,gdal2.4.4 还是像之前在Unity中应用gdal一样,最好是下载已经编译好的C#版的gdal,不然自己配置真的很容易出错,我就是这样的,下面提供不同版本的gdal下载地址: 1.GDAL2.4.4(C#版、64位): https://download.csdn.net/download/che

chengbaola的博客 1365

流量特征工程实战:基于Python脚本的CIC-FlowMeter批量自动化处理

本文详细介绍了如何利用Python脚本对CIC-FlowMeter工具进行批量自动化封装,实现从海量PCAP文件中高效提取流量特征并生成CSV文件。通过构建健壮的自动化流水线,解决了手动处理效率低下、易出错的问题,并分享了并行处理、错误处理等关键优化技巧,助力网络流量分析与机器学习数据预处理工作。

c6d7e8f9g的博客 744

【IDEA】如何完美的修改重命名一个SpringBoot项目工程名称

自己之前做好了一个基础的web项目框架web-basic,打算以后开发的时候,都从这个框架开始进行项目的开发,如果以后有心情的话,可能会一直维护好这个框架。自己今天准备开始一个新的项目名字叫pts8000,所以把web-basic项目拷贝过来,最上面一层根目录文件夹的名字已修改为pts8000。 修改项目名称主要有以下步骤: 1. 修改项目根目录文件夹名称 在操作系统里,将根目录的文件夹名称从web-basic改为pts8000。 修改之后,使用Idea的Open工具,打开项目的根目录,进入项目中,可以

HD243608836的博客 1万+

Zotero搭配CNKI.js插件:一键批量下载知网文献的完整教程(附常见问题解决)

本文提供Zotero搭配CNKI.js插件实现知网文献批量下载的完整教程。详细介绍了从环境准备、插件安装到实战操作的全流程,并针对常见问题提供解决方案,旨在帮助科研人员高效构建自动化文献管理工作流,显著提升文献收集与整理效率。

e4f5g6h7的博客 1201

更改springboot默认加载的application.yml文件的名字为xx.yml(自定义名字

更改springboot默认加载的application.yml文件的名字为xx.yml(自定义名字) new SpringApplicationBuilder(AppWeiXin.class) .properties("spring.config.location=classpath:/xx.yml").run(args);

yundanfengqingyou的博客 5963

【人工智能之深度学习】12. BERT微调实战:医疗文本分类的领域自适应技巧与工业级实现

摘要:医疗文本分类是自然语言处理在医疗健康领域的核心应用,可辅助疾病诊断、病历结构化和医疗质量监控。然而,医疗文本的专业术语密集、实体关系复杂及数据长尾分布等特性,导致通用BERT模型性能受限。本文系统阐述医疗文本分类的领域自适应技术,从理论原理到工业级实现展开全流程讲解。首先分析医疗文本的独特属性及技术挑战;随后详解领域继续预训练、适配器微调、对抗训练等核心技术的数学原理;构建包含数据预处理、模型优化、隐私保护的完整实战架构;通过疾病分类、情感分析、事件检测三大案例验证技术有效性。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 1005

网页内容抓取的艺术:使用R语言解析动态网页

本文探讨了使用R语言处理动态网页数据的方法。针对AJAX加载的学术网站,传统的静态抓取和RSelenium方法存在会话终止、浏览器错误等问题。通过分析发现内容通过admin-ajax.php加载,提出使用httr2模拟POST请求获取数据,配合rvest解析HTML内容。该方法避免了浏览器自动化的弊端,实现了高效稳定的动态内容提取,为处理类似AJAX网站提供了通用解决方案。

m0_74337424的博客 54

SpringBoot 的配置文件 application.properties的位置问题&&文件问题

在SpringBoot中,很神奇的事,不管是tomcat等服务器,还是mysql等数据库,还是其他一些配置可以在application.properties中进行配置,而使用默认的时候,也就是新建项目的时候,application.properties是在resources资源文件下的,无需做其他的事,你只有按这么写就可以生效,但是我还没开始看源码,所以心里不是很靠谱,后面还自己去看看。 在 Sp...

qq_37432174的博客 2324

STC单片机使用FatFs文件系统读取SD卡指定文件内容

STC单片机使用FatFs文件系统读取SD卡指定文件内容

perseverance51博客 2744

SpringBoot 配置文件 application.yml(application.properties) 配置大全

参考网址:https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html 可以在application.properties文件内部application.yml,文件内部或命令行开关中指定各种属性。本附录提供了常见Spring Boot属性的列表以及对使用它们的基础...

真是6的不行的博客 8014

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

application.properties配置文件

application.properties配置文件 数据库 spring.datasource.url=jdbc:mysql://127.0.0.1:3306/project?characterEncoding=UTF-8 spring.datasource.username=root spring.datasource.password=admin spring.datasource.driv...

sky 2310

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

application.properties配置文件详解

SpringBoot核心配置文件application.properties详解:该文件用于定义应用运行时的各类参数,覆盖应用核心、数据源、Web、安全、缓存等十余个功能模块。主要配置项包括:应用名称/端口(spring.application.name/server.port)、数据源(spring.datasource.*)、ORM框架(JPA/MyBatis)、Web服务器(Tomcat/Jetty)、安全(SpringSecurity)、缓存(Redis/Caffeine)、日志级别(logging

魏波 1787

SpringBoot配置文件application.properties的理解

如果我们不在这4个位置也想加载我们的配置文件的话,我们可以在resources目录下创建一个新目录命名为myconfig,目录下存放一个application.properties文件。我们可以在打包成jar的情况下在启动命令中加入配置文件的参数,就可以启动自定义的配置。我们的application.properties文件名称也可以修改,比如修改成app.properties。我们可以在打成jar包的情况下在启动命令下加入配置文件名的参数,就可以使用自定义配置文件名。

qinxun2008081的博客 2463

SpringBoot的配置文件详解

(表示的意思是一样,只是例1:在application.properties中设置服务器的端口号和web应用的上下文(项目的根路径)例2: application.yml设置服务器的端口号和web应用的上下文(项目的根路径)

m0_61925586的博客 2140

Spring Boot (六)——详解配置文件 application.properties

详解配置文件 application.properties 在 Spring Boot 中,配置文件有两种不同的格式,一个是 properties ,另一个是 yaml 。 虽然 properties 文件比较常见,但是相对于 properties 而言,yaml 更加简洁明了,而且使用的场景也更多,很多开源项目都是使用 yaml 进行配置(例如 Hexo)。除了简洁,yaml 还有另外一个特点,...

云中、漫步的博客 1569

SpringBoot 核心配置文件:application.yml 与 application.properties

为啥有时候配了不生效?今天就把这两个配置文件讲透,包括语法、优先级、常用配置、踩坑点,看完你就能随心所欲配置 SpringBoot 项目。不管是改端口、配数据库连接,还是调日志级别,SpringBoot 里所有“个性化配置”几乎都要靠核心配置文件——② application.yml 写法(层级化,用缩进分隔,冒号后必须加空格):YAML 格式(层级化写法,更简洁,大厂主流)。

。。。 1362

Spring Boot(四)-- 中的application.properties配置简介1

Spring Boot中的application.properties配置简介   我们用过Spring Boot的程序猿都知道,Spring Boot中的配置文件有两种格式,properties或者yaml,一般情况下,两者可以随意使用,选择自己喜欢的就可以,但是这中配置完全不一样的。本文就介绍application.properties配置方式的问题。 问题一:存放的位置问题 位置问题一:默认...

知性人 -- 的博客 2015

创建springboot项目关于applica.properties文件配置

这里写自定义目录标题springboot项目application.properties配置src->main->resources->application.properties springboot项目application.properties配置 这是我最近看慕课网廖师兄的java支付与电商双系统实战课时,记录springboot开发项目时相关注意事项。也是我发布的第一篇博客,写的不太好请大家多多谅解。 src->main->resources->applicat

weixin_50874065的博客 1721

java之学习记录 9 - 1 - SpringBoot全局配置文件、自定义配置文件

全局配置文件能够对一些默认配置值进行修改。Spring Boot使用一个application.properties或者application.yaml的文件作为全局配置文件,该文件存放在src/main/resource目录或者类路径的/config,一般会选择resource目录。接下来,将针对这两种全局配置文件进行讲解 : Spring Boot配置文件的命名及其格式: application.properties application.yaml application.yml 1 a

dear_zx的博客 3280

04.一语详解SpringBoot全局配置文件

全局配置文件能够对一些默认配置值进行修改。Spring Boot使用一个application.properties或者application.yaml的文件作为全局配置文件,该文件存放在src/main/resource目录或者类路径的/config,一般会选择resource目录。............

程序员阿红的博客 1634

SpringBoot application.properties 配置文件

服务器端口,指定 Spring Boot 内嵌服务器(如 Tomcat)运行的端口号为 8080。访问 Web 应用时,可以通过。#设置 Spring Boot 应用的名称为?,这个名称通常用于服务注册与发现。#数据库驱动,指定数据库的 JDBC 驱动类,这里使用 MySQL 的官方驱动。#数据源名称,Spring Boot 默认不会使用 这个配置(可以忽略)#数据库连接地址,连接本地 MySQL 数据库 (指定数据库的时区为 UTC,避免时区问题。数据库名称写入括号内()#数据库用户名&密码。

qq_63051358的博客 343
下一篇: JDK8 Optional容器类的常用方法总结
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值