Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Estas instruções ajudarão a implantar o aplicativo de referência Cloud Foundry Spring
Music usando o Cloud Service Broker do Kf para o Google Cloud.
Criação de aplicativos Java da origem: a origem do Spring Music será criada
no cluster, não localmente.
Integração do agente de serviços: você criará um banco de dados usando o Cloud Service Broker do Kf e vinculará o aplicativo Spring Music a ele.
Conectores do Spring Cloud: os Conectores do Spring Cloud são usados pelo aplicativo Spring Music para
detectar itens como serviços vinculados do CF. Eles funcionam perfeitamente com o Kf.
Configuração da versão do Java: especifique a versão do Java para o
buildpack usar.
Edite manifest.yml e substitua path: build/libs/spring-music-1.0.jar por stack: org.cloudfoundry.stacks.cflinuxfs3. Isso instrui o Kf a criar da origem usando buildpacks nativos da nuvem para que você não precise compilar localmente.
Use o recurso de proxy para acessar o aplicativo implantado.
Inicie o proxy:
kfproxyspring-music
Abra http://localhost:8080 no seu navegador:
O aplicativo implantado inclui um elemento da interface que mostra qual perfil do Spring (se houver) está sendo usado. Nenhum perfil está sendo usado aqui, o que indica que um banco de dados na memória está em uso.
Criar e vincular um banco de dados
Crie um banco de dados PostgresSQL no marketplace.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-04 UTC."],[],[],null,["# Deploy Spring Music\n\nThese instructions will walk you through deploying the [Cloud Foundry Spring\nMusic](https://github.com/cloudfoundry-samples/spring-music) reference App using the Kf Cloud Service Broker for Google Cloud.\n\n1. **Building Java Apps from source**: The Spring Music source will be built on\n the cluster, not locally.\n\n2. **Service broker integration**: You will create a database using the Kf Cloud Service Broker and bind the Spring Music App to it.\n\n3. **Spring Cloud Connectors** : [Spring Cloud\n Connectors](https://cloud.spring.io/spring-cloud-connectors/) are used by the Spring Music App to\n detect things like bound CF services. They work seamlessly with Kf.\n\n4. **Configuring the Java version**: You will specify the version of Java you\n want the buildpack to use.\n\nPrerequisites\n-------------\n\n[Install and configure Kf Cloud Service Broker](/migrate/kf/docs/2.11/how-to/deploying-cloud-sb).\n\nDeploy Spring Music\n-------------------\n\n### Clone source\n\n1. Clone the [Spring Music repo](https://github.com/cloudfoundry-samples/spring-music).\n\n git clone https://github.com/cloudfoundry-samples/spring-music.git spring-music\n cd spring-music\n\n2. Edit `manifest.yml`, and replace `path: build/libs/spring-music-1.0.jar` with `stack: org.cloudfoundry.stacks.cflinuxfs3`. This instructs Kf to build from source using [cloud native buildpacks](/blog/products/containers-kubernetes/google-cloud-now-supports-buildpacks) so you don't have to compile locally.\n\n ---\n applications:\n - name: spring-music\n memory: 1G\n random-route: true\n stack: org.cloudfoundry.stacks.cflinuxfs3\n env:\n JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{enabled: false}'\n # JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 11.+ } }'\n\n### Push Spring Music with no bindings\n\n1. Create and target a Space.\n\n kf create-space test\n kf target -s test\n\n2. Deploy Spring Music.\n\n kf push spring-music\n\n3. Use the proxy feature to access the deployed App.\n\n 1. Start the proxy:\n\n kf proxy spring-music\n\n 2. Open `http://localhost:8080` in your browser:\n\n The deployed App includes a UI element showing which (if any) Spring profile is being used. No profile is being used here, indicating an in-memory database is in use.\n\n### Create and bind a database\n\n1. Create a PostgresSQL database from the marketplace.\n\n **Note:** You must set the `COMPUTE_REGION` and `VPC_NAME` variables so Kf Cloud Service Broker knows where to provision your instance, and authorize the VPC Kf Apps run on to access it. \n\n kf create-service csb-google-postgres small spring-music-postgres-db -c '{\"region\":\"\u003cvar translate=\"no\"\u003eCOMPUTE_REGION\u003c/var\u003e\",\"authorized_network\":\"\u003cvar translate=\"no\"\u003eVPC_NAME\u003c/var\u003e\"}'\n\n2. Bind the Service with the App.\n\n kf bind-service spring-music spring-music-postgres-db\n\n3. Restart the App to make the service binding available via the VCAP_SERVICES environment variable.\n\n kf restart spring-music\n\n4. (Optional) View the binding details.\n\n kf bindings\n\n5. Verify the App is using the new binding.\n\n 1. Start the proxy:\n\n kf proxy spring-music\n\n 2. Open `http://localhost:8080` in your browser:\n\n You now see the Postgres profile is being used, and we see the name of our Service we bound the App to.\n\nClean up\n--------\n\n1. Unbind and delete the PostgreSQL service:\n\n kf unbind-service spring-music spring-music-db\n kf delete-service spring-music-db\n\n2. Delete the App:\n\n kf delete spring-music"]]