[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],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 with Kf, demonstrating a few things along the\nway:\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 and bind a PostgreSQL\n database to the Spring Music App.\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### Option 1: Minibroker\n\nThe cluster administrator should follow [these instructions](/migrate/kf/docs/2.3/how-to/minibroker)\nto install the Minibroker service broker into your cluster. Minibroker will\nallow you to provision a PostgreSQL database and configure your App to use it.\n\nTo confirm that Minibroker is installed and available to your cluster, run `kf\nmarketplace` and you should see output similar to: \n\n $ kf marketplace\n 5 services can be used in Space \"demo\", use the --service flag to list the plans for a service\n\n Broker Name Space Status Description\n minibroker mariadb Active Helm Chart for mariadb\n minibroker mongodb Active Helm Chart for mongodb\n minibroker mysql Active Helm Chart for mysql\n minibroker postgresql Active Helm Chart for postgresql\n minibroker redis Active Helm Chart for redis\n\n### Option 2: Other Service Broker\n\nYou can use a different service broker that's installed as long as it supports\ncreating PostgreSQL services. For example, the [gcp-service-broker]().\n\nDeploy\n------\n\n### Clone source\n\n1. Clone the [Spring Music repo](https://github.com/cloudfoundry-samples/spring-music).\n\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 the contents with the following:\n\n ---\n applications:\n - name: spring-music\n memory: 1G\n random-route: true\n stack: org.cloudfoundry.stacks.cflinuxfs3\n env:\n BP_AUTO_RECONFIGURATION_ENABLED: false\n\n### Push App\n\n1. Deploy (this assumes you've already `kf target`ed a Space; see [these\n docs](../quickstart#prepare_space) for more detail):\n\n kf push spring-music\n\n2. Use the proxy feature to access the deployed App, then load\n `http://localhost:8080` in your browser:\n\n kf proxy spring-music\n\n \u003e The deployed App includes a UI element showing which (if any) Spring\n \u003e profile is being used. No profile is being used here, indicating an\n \u003e in-memory database is in use.\n\n### Create and bind database\n\n1. Create a PostgreSQL service via the broker installed in the marketplace:\n\n kf create-service postgresql 11-7-0 spring-music-db -c '{\"postgresqlDatabase\":\"smdb\", \"postgresDatabase\":\"smdb\"}'\n\n2. Bind the service instance to the Spring Music App:\n\n kf bind-service spring-music spring-music-db -c '{\"postgresqlDatabase\":\"smdb\", \"postgresDatabase\":\"smdb\"}'\n\n3. Restart the App to make the service binding available via the `VCAP_SERVICES`\n environment variable:\n\n kf restart spring-music\n\n4. (Optional) View the binding details:\n\n kf bindings\n\n5. `kf proxy` to the App again and view it in your web browser. The Spring\n profile should be shown, indicating the PostgreSQL service you created and\n bound is being used:\n\nDestroy\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"]]