Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Diese Anleitung führt Sie durch die Bereitstellung der Referenzanwendung Cloud Foundry Spring Music mit Kf Cloud Service Broker für Google Cloud.
Java-Anwendungen aus der Quelle erstellen: Die Spring Music-Quelle wird auf dem Cluster erstellt, nicht lokal.
Service Broker-Einbindung: Sie erstellen mit Kf Cloud Service Broker eine Datenbank und binden dann die Spring Music-Anwendung an diese Datenbank.
Spring Cloud Connectors:Spring Cloud Connectors werden von der Spring Music App verwendet, um Dinge wie gebundene CF-Dienste zu erkennen. Sie funktionieren nahtlos mit Kf.
Java-Version konfigurieren: Sie geben die Java-Version an, die vom Buildpack verwendet werden soll.
Bearbeiten Sie manifest.yml und ersetzen Sie path: build/libs/spring-music-1.0.jar durch stack: org.cloudfoundry.stacks.cflinuxfs3. Damit wird Kf angewiesen, mit cloudnativen Buildpacks aus der Quelle zu erstellen, sodass Sie nicht lokal kompilieren müssen.
Verwenden Sie die Proxyfunktion, um auf die bereitgestellte Anwendung zuzugreifen.
Starten Sie den Proxy:
kfproxyspring-music
Öffnen Sie http://localhost:8080 in Ihrem Browser:
Die bereitgestellte Anwendung enthält ein UI-Element, das angibt, welches Spring-Profil gegebenenfalls verwendet wird. Hier wird kein Profil verwendet, was auf die Verwendung einer In-Memory-Datenbank hinweist.
Datenbank erstellen und binden
Erstellen Sie eine PostgresSQL-Datenbank aus dem Marketplace.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-31 (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"]]