-
-
Save pctimm/ef2ac72a4a6d9163d1a872c4d698574a to your computer and use it in GitHub Desktop.
Como usar variáveis de ambiente no VS Code (para aplicações Spring Boot)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Localização: pctimm/projetos/meuprojeto (VS.Code Workspace)/.env | |
| # Cuidar para não adicionar as " " (aspas) pois isso será lido junto. | |
| # Formato: CHAVE_VARIAVEL=valor-variavel | |
| DB_USERNAME=rootusername | |
| DB_PASSWORD=root.senha123 | |
| DB_NAME=database | |
| DB_URL=localhost:3306 | |
| # 3306 = porta padrão MYSQL | |
| # Não esquecer de configurar corretamente porta... e etc. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Todas as outras propriedades do gitignore... | |
| ### VS Code ### | |
| .vscode/ | |
| .env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Localização: pctimm/projetos/meuprojeto (VS.Code Workspace)/src/main/resources/application.properties | |
| spring.datasource.url=jdbc:mysql://${DB_URL}/${DB_NAME} | |
| spring.datasource.username=${DB_USERNAME} | |
| spring.datasource.password=${DB_PASSWORD} | |
| spring.config.import=optional:file:.env[.properties] | |
| # suas outras propriedades... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Localização: pctimm/projetos/meuprojeto (VS.Code Workspace)/.vscode/launch.json | |
| // Foi adicionado o "envFile" nas configurações de execução do projeto Spring. | |
| { | |
| // Use IntelliSense to learn about possible attributes. | |
| // Hover to view descriptions of existing attributes. | |
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | |
| "version": "0.2.0", | |
| "configurations": [ | |
| { | |
| "type": "java", | |
| "name": "Current File", | |
| "request": "launch", | |
| "mainClass": "${file}" | |
| }, | |
| { | |
| "type": "java", | |
| "name": "MeuProjetoSpringApplication", | |
| "request": "launch", | |
| "mainClass": "com.meuprojeto.api.MeuProjetoSpringApplication", | |
| "projectName": "meuprojeto-api", | |
| "envFile": "${workspaceFolder}/.env" | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment