This tutorial shows you how to create a Java web application with Visual Studio Code. You'll learn how to run, debug, and edit the Java web app locally and eventually on the cloud. Show
ScenarioA simple Spring Boot Getting Started web app Before you beginBefore running and deploying this sample, you must have the Java SE Development Kit (JDK) and Apache Maven build tools on your local development environment. If you don't have, please install them. Download and install the Extension Pack for Java, which has JDK 11 included.
Download Apache Maven version 3 or greater: Download Apache Maven Install Apache Maven for your local development environment: Install Apache Maven Download and test the Spring Boot appClone the Spring Boot Getting Started sample project to your local machine. You can clone a Git repository with the Git: Clone command in the Command Palette
(⇧⌘P (Windows, Linux Ctrl+Shift+P)). Paste
From within VS Code, open any of the Java files within the Once you have the Extension Pack for Java installed, it will
automatically build the project for you (this may take several minutes). You can run the application within VS Code by pressing F5 and selecting the Java environment. The Java Debug extension will generate a debugging configuration file You can learn more about how VS Code launches your application in Debugging Launch Configurations. Press F5 again to launch the debugger. Test the web app by browsing to http://localhost:8080 using a web browser. You should see the following message displayed: "Greetings from Spring Boot!". Make a changeLet's now edit Click the Restart button on the top of the editor to relaunch the app and see result by reloading the browser. Debug the applicationSet a breakpoint (F9) in the application source code, and reload your browser to hit the breakpoint. If you would like to learn more about debugging Java with VS Code, you can read Java Debugging. Congratulations, you have your first Spring Boot web app running locally! Read on to learn how to host it in the cloud. Deploy Web Apps to the cloudWe just built a Java web application and ran it locally. Now you will learn how to deploy from Visual Studio Code and run it on Azure in the cloud. If you don't have an Azure subscription, you can sign up for a free Azure account. Create your free Azure account Install the Azure App Service extensionThe Azure App Service extension is used to create, manage, and deploy to Azure App Service with key features including:
To
install the Azure App Service extension, open the Extensions view (⇧⌘X (Windows, Linux Ctrl+Shift+X)) and search for Create a new Web App on AzureOnce the extension is installed, you can take the following steps to create a new Web App on Azure.
Build and deploy to a Web AppThe deploy process leverages the Azure Account extension (installed along with the Azure App Service extension as a dependency) and you need to sign in with your Azure subscription. If you do not have an Azure subscription, sign up today for a free 30 day account and get $200 in Azure Credits to try out any combination of Azure services. To sign in to Azure, run Azure: Sign In from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)). You can then sign in to your account using the Device Login flow. Select Copy & Open to open your default browser. Paste in the access code and continue the sign in process. Once you have signed in,
you can open the command prompt or terminal window and build the project using Maven commands. This will generate a new
After building the project, open the Open the Output window in VS Code to view the deployment logs. Once the deployment is completed, it will print out the URL for your Web App. Click the link to open it in a browser, you can see the web app running on Azure!
Connect with data servicesAzure Cosmos DB is a globally distributed database service that allows developers to work with data using a variety of standard APIs, such as SQL, MongoDB, Cassandra, Graph, and Table. The Spring Boot Starter makes it easy to store data in and retrieve data from your Azure Cosmos DB with SQL API. Create an Azure Cosmos DB entity on Azure
Config your project
Run and debug the applicationYou can press F5 to run your application. To check the result, open Azure portal and access your Cosmos DB. Click Data Explorer, and next choose Documents. You will see data being shown if it is successfully written into Cosmos DB. You can also browse your data entries in Cosmos DB with Azure Databases extension. After setting a breakpoint (F9) in your source code, refresh your browser to hit the breakpoint. Details about debugging can be found in Java Debugging Alternatively, you can also use Maven to package and run your project as steps below:
Next steps
11/11/2020 Apakah Python sama dengan Java?Apakah Python Sama dengan Java? Python tidak sama dengan Java. Meskipun keduanya bisa digunakan untuk tujuan umum, sama-sama bahasa tingkat tinggi, dan object-oriented, keduanya memiliki banyak perbedaan.
Kenapa Python lebih baik dari Java?Alasan utama memulai dengan Python adalah bahwa jalur pembelajaran mereka paling cocok untuk pemula daripada Java. Namun, setelah beberapa waktu, akan menjadi ide yang brilian juga untuk memperoleh dasar-dasar Java sebagai pengalaman Anda. Juga, sintaks Python jauh lebih mudah dipelajari daripada Java.
Python bisa digunakan untuk apa saja?Python adalah sebuah bahasa pemrograman yang digunakan untuk membuat aplikasi, perintah komputer, dan melakukan analisis data. Sebagai general-purpose language, Python bisa digunakan untuk membuat program apa saja dan menyelesaikan berbagai permasalahan. Selain itu, Python juga dinilai mudah untuk dipelajari.
Apa itu Python Java?Python dan Java adalah bahasa pemrograman dasar dari ilmu komputer, mereka adalah alat mendasar dalam kotak alat programmer dan penting untuk hampir setiap kegiatan pemrograman.
|