Spring Boot installation and use 2021.10.28
- 1. Introduction to Spring Boot
- 2. Spring Boot installation prerequisite environment (Java must + Maven / Gradle)
- 3. Spring Boot project example Demo
-
- 3.1 Using Notepad as IDE
- 3.2 Using Eclipse as IDE
- 3.3 Using VSCode as IDE
- 3.4 Using IDEA as IDE
- 4、Spring Boot CLI
1. Introduction to Spring Boot
Spring makes Java programming easyfaster、simpler、safer. Spring
It has become the most popular Java
framework in the world due to the great focus on speed, simplicity and productivity of project construction .
1.1 Why choose Spring?
The Why Spring? Spring
framework can be accompanied by a large number of tool libraries, which can save developers from writing a lot of extra code, thereby saving development time and energy and effectively improving development efficiency.
- Spring is everywhere : Whether it's streaming TV, online shopping, or countless other innovative solutions, developers around the world trust and use Spring libraries to deliver delightful experiences to millions of end users every day. experience. Of course, many of them come from alltechnology giantContributions from Alibaba , Amazon , Google , Microsoft, etc.
- Spring is flexible (more flexible) : Developers can use
Spring
a flexible and comprehensive set of extensions and third-party libraries to build almost any application imaginable. Whether developers areweb
building secure, reactive, cloud-based microservices for the enterprise or complex streaming data flows for the enterprise, itSpring
can help. - Spring is productive :
SpringBoot
Combinesweb
essentials like application context and an auto-configured embedded server to make microservices development a breeze. Thanks toSpringBoot
changing the way of handling Java programming tasks, developers can combineSpring Boot
withSpring Cloud
rich supporting libraries, servers, patterns and templates to safely deploy the entire microservices-based architecture to the cloud in as little time as possible. - Spring is fast :
Spring
Projects are increasingly supporting a reactive (non-blocking) programming model for greater efficiency and better performance, enabling fast startup , fast shutdown , and optimized execution by default .SpringBoot
It can help developers build applications easily and effortlessly, and even use Spring initializers to start a newSpring
project in seconds. - Spring is secure :
Spring
Committers work with security professionals to patch and test any reported vulnerabilities, while third-party dependencies are closely monitored and updates are released regularly to ensure data and application security . In addition,Spring Security
it makes it easier for developers to integrate with industry-standard security solutions, and provides safe and reliable solutions by default. - Spring is supportive (supported more) : As a large, global, and diverse community,
Spring
the community covers developers of all ages and abilities, from complete beginners to seasoned professionals. Wherever a developer is, he can find the support and resources he needs.
1.2 Functions of Spring
Spring
The following functions can be realized:
(1) Microservice (Microservices), the microservice architecture has gradually become a new normal. Building small, self-contained, ready-to-run applications brings great flexibility and extra resilience to your code. SpringBoot
Many purpose-built features in make it easy for users to build and run your microservices in production at scale.
(2) Sensitive response system (Reactive), reactive systems have certain properties that make them ideal for low-latency, high-throughput workloads. Project Reactor
Works in tandem with Spring
the product portfolio to enable developers to build responsive, resilient message-driven, enterprise-grade reactive systems.
(3) Cloud operation (Cloud), developing distributed systems can be challenging. Complexity moves from the application layer to the network layer, requiring greater interaction between services. Code " cloud native " means dealing with the 12-factor concerns of external configuration, statelessness, logging and connecting to supporting services, and the SpringCloud
project suite contains many of the services needed to make an application run in the cloud.
(4) Convenient network application (Web Applications), by removing most of web
the development-related boilerplate code and configuration, it Spring
implements a modern web
programming model that simplifies the development of server-side HTML
applications, REST API
and bi-directional, event-based systems, making building web
applications fast and convenient.
(5) Serverless (Serverless), serverless applications take advantage of modern cloud computing features and abstractions, allowing developers to focus on logic rather than infrastructure. In a serverless development environment, developers only need to focus on writing application code, while the underlying platform takes care of scaling, runtime, resource allocation, security, and other " server " specifications.
(6) Event-driven (Event Driven), event-driven systems reflect how modern businesses actually work ( thousands of small changes happen every day ). Spring's ability to handle events and enable developers to build applications around events means that applications will stay in sync with the business. Spring has many event-driven options to choose from, from integration and streaming all the way to cloud functions and dataflows.
(7) Batch processing (Batch), batch processing is able to efficiently process large amounts of data, which makes it well suited for many use cases. SpringBatch
The implemented industry standard processing patterns allow you JVM
to build robust batch jobs on top of it. Mission-critical batch applications can be built by Spring
adding and other components from the portfolio .Spring Boot
1.3 Dependency package management tools for Spring projects (Maven or Gradle)
The comparison between Maven and Gradle , their differences are mainly reflected in four aspects: flexibility , performance , user experience and dependency management .
- Flexibility:
以用户为中心,Gradle更加偏重底层基础,可扩展性强,易于建模,不仅允许使用C/C++进行本机开发,还可以扩展到任何生态系统
. - Performance:
就提高构建时间并加快发布速度而言,Gradle和Maven都采用某种形式的并行项目构建和并行依赖解析。最大的区别在于Gradle的工作回避机制和递增机制。Gradle和Maven用户都可以利用Gradle Enterprise中可用的构建缓存技术。Gradle用户通常会额外减少约50%的构建时间,而Maven用户通常会减少约90%
.
- User Experience:
历史深远的Maven通过IDE提供的支持对许多用户来说更好。然而,Gradle的IDE支持继续快速改进。Gradle提供了一个交互式的基于web的UI,用于调试和优化构建:[Build Scan](https://gradle.com/build-scans?_ga=2.40948836.711658238.1635427287-13996288.1635427287). 这些也可以在本地托管,以允许组织收集构建历史并进行趋势分析、比较构建以进行调试或优化构建时间
. - Dependency management:
作为库使用者,Maven允许覆盖依赖项,但只能按版本覆盖。Gradle提供了可定制的依赖项选择和替换规则,这些规则可以声明一次并处理项目范围内不需要的依赖项。这种替代机制使Gradle能够一起构建多个源项目以创建复合构建。Maven几乎没有内置的依赖范围,Gradle允许自定义依赖范围,从而提供更好的建模和更快的构建。作为库生产者,Gradle允许生产者声明'api'和'implementation'依赖项,以防止不需要的库泄漏到使用者的类路径中。Maven允许发布者通过可选的依赖项提供元数据,但仅作为文档。Gradle完全支持功能变体和可选依赖项
.
2. Spring Boot installation prerequisite environment (Java must + Maven / Gradle)
2.1 Install Java
Go to the Java download page on Oracle’s official website to download the Java version you need. The Java 8 version is used here jdk-8u221-windows-x64.exe
. Double-click to run and select the installation directory you want. Because the JDK
installation package will install the corresponding version JDK
and at the same time JRE
, the installation is successful here. The resulting directory is shown in the figure below.
Then set the environment variable for Java, first create a new system environment variable JAVA_HOME
, set its value D:\Program Files (x86)\Java\jdk1.8.0_221
(that is, the JDK installation directory); then create a new system environment variable classpath
, set its value .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
, and then add it to the value of the system environment variable Path %JAVA_HOME%\bin;
. Finally Win+ Ropen the cmd command line window, enterjava -versionjava
After pressing Enter, if the corresponding version appears , the environment configuration is successful.
2.2 Maven configuration
Before you are ready to install Maven, you need to install it JDK 1.7+
. Go to the Maven official website to download the latest version Maven 3.8.3
, or download the historical version from the Maven Archive library according to your own needs Maven
. Here, you can download apache-maven-3.8.3-bin.zip
the compressed package free of installation files and unzip it to the D drive .
Then create a new system environment variable MAVEN_HOME
, set its value D:\program files\apache-maven-3.8.3
, and add its subdirectory bin
folder to the system environment variable Path
. In addition, note that you should also create a new system environment variable M2_HOME
, and set its value to D:\program files\apache-maven-3.8.3
(In order for the Spring Boot project to be able to find the needs of the Maven directory)。
Win+ ROpen the cmd command line window, enter mvn --version
, if the Maven version prompt appears, the Maven configuration is successful.
Then, after creating a new folder Maven
in the installation directory , open the files in the folder , and add the local warehouse location in the corresponding position in the figure below ;repository
conf
settings.xml
D:\program files\apache-maven-3.8.3\repository
<localRepository>D:\program files\apache-maven-3.8.3\repository</localRepository>
At the same time, maven
the modified download address is the Alibaba Cloud mirror source, and mirrors
the following code is added inside:
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
In order to check whether the download link of Maven warehouse and Mirror image has been successfully set up, enter in the console mvn help:system
and finally promptBuild SuccessAt the same time, D:\program files\apache-maven-3.8.3\repository
download the relevant dependency packages in the warehouse folder, as shown in the figure below.
There will also be related folders generated under Maven仓库
the folder ( D:\program files\apache-maven-3.8.3\repository
), and there will be corresponding jar
package dependencies under the folder ( such as slf4j-api-1.7. 5.jar )
2.3 Gradle configuration
Download the installation package file on the official website of Gradle , and then put the decompressed folder into the directoryGradle 7.2
gradle-7.2-all.zip
D:\program files\gradle-7.2
Then right-click on the computer and select Properties -> Advanced System Settings -> Environment Variables to find the system environment variable Path
, add it to its value D:\program files\gradle-7.2\bin
and confirm, and finally open the cmd window gradle -v
to input to verify whether the configuration is successful. If the version number Gradle
appears, the configuration is successful. Next, modify the location of the local warehouse, and set its value by creating a new system environment variable . In order to ensure the download speed and success rate of the dependent library, it is recommended to create a file under the corresponding folder for the configured domestic image download address , and enter the following content:Gradle
Gradle
GRADLE_USER_HOME
D:\program files\gradle-7.2\GradleRepository\.gradle
Gradle
Gradle
GRADLE_USER_HOME
init.gradle
allprojects {
repositories {
def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/public'
all {
ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith('https://repo1.maven.org/maven2')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
remove repo
}
}
}
maven {
url ALIYUN_REPOSITORY_URL }
}
}
3. Spring Boot project example Demo
参考Spring Quickstart Guide和Building an Application with Spring Boot。
3.1 Using Notepad as IDE
3.1.1 Create a new Spring Boot project managed by Maven and run it as a jar package
To use the online Spring Initializr to create a new Maven
management Spring Boot
project, you need to make the following settings, Project selection Maven Project
, Language selection Java
, Spring Boot version selection 2.5.6
, Group setting com.example.test
, Artifact setting demomavenspringboot
, Name setting demomavenspringboot
, Description setting Demo project for Spring Boot
, Package name setting com.example.test.demomavenspringboot
, Packing packaging method selection Jar
, Java version selection 8
, Dependencies selection on the right Spring Web
and click the bottomGenerate, the compressed package file corresponding to the project will be downloadeddemomavenspringboot.zipand unzip to a folder.
The demomavenspringboot project folder is shown in the figure above, use Notepad Notepad
to open the file under src\main\java\com\example\test\demomavenspringboot Modify the code as shown below, and then in the project root directoryDemomavenspringbootApplication.java
DemomavenspringbootApplication.java
F:\workspace\MydemoSpringBoot\demomavenspringbootStart the cmd command line window and enter the command mvnw spring-boot:run
to start the project.
package com.example.test.demomavenspringboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class DemomavenspringbootApplication {
public static void main(String[] args) {
SpringApplication.run(DemomavenspringbootApplication.class, args);
}
@GetMapping("/hello")
public String hello(@RequestParam(value = "name", defaultValue = "World") String name)
{
return String.format("Hello %s!", name);
}
}
After starting and running, the project will automatically create a new C:\Users\Lenovo.m2 folder (ieC:\Users\your username.m2 folder), there are two folders repository and wrapper under the folder, of whichwrapperfolder is automatically downloaded apache-maven-3.8.3
, while therepositoryThe folder stores the relevant dependent jar package files downloaded from the Maven central library during project operation (you can C:\Users\Lenovo\.m2\wrapper\dists\apache-maven-3.8.3-bin\5a6n1u8or3307vo2u2jgmkhm0t\apache-maven-3.8.3\conf文件夹下的settings.xml
check it from the file, Note: You can set it to other disk folders according to your own needs to save space on the C disk ).
After the project starts successfully , open Google Chrome and visit http://localhost:8080/ , http://localhost:8080/hello , http://localhost:8080/hello?name=notepad123 in turn , the result is shown in the figure below, Then use the keyboard + and enter in the cmd window to end the operation.CtrlCY
In order to modify the port number port, you can edit the files under the src\main\resources folder, the content is as follows:application.properties
server.port=8081
server.servlet.context-path=/Notepad
At the same time, in order to modify the default page, you can create a new file (default page) and file (custom access page) under the src\main\resources\static folder . document contentindex.html
cesiummyexample.html
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>index.html</title>
</head>
<body>
Hello Spring Boot!
</body>
</html>
cesiummyexample.html
document content
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Include the CesiumJS JavaScript and CSS files -->
<script src="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Cesium.js"></script>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
<div id="cesiumContainer"></div>
<script>
// Your access token can be found at: https://cesium.com/ion/tokens.
// Replace `your_access_token` with your Cesium ion access token.
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4ZDdhNmRjMC0yNGMxLTRlYWItYjU5Ny1jZjJjZWIyNWI2YmIiLCJpZCI6NzY2Niwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU1MDExMjI4NH0.e_LkplBoPjo_fSqLsGAb97ypotS0G5tMHJoSxLkqyUw';
// Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
const viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider: Cesium.createWorldTerrain()
});
// Add Cesium OSM Buildings, a global 3D buildings layer.
const buildingTileset = viewer.scene.primitives.add(Cesium.createOsmBuildings());
// Fly the camera to San Francisco at the given longitude, latitude, and height.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-122.4175, 37.655, 400),
orientation : {
heading : Cesium.Math.toRadians(0.0),
pitch : Cesium.Math.toRadians(-15.0),
}
});
</script>
</div>
</body>
</html>
Then use the cmd command line window to start the project in the root directory of the project and then exit , you can use mvnw clean package
the command to type the project intojar package, and then use the command to run the project in the cmd windowjava -jar xxx.jar
, which is simple, trouble-free and highly portable.
At this time, use Google Chrome to visit http://localhost:8081/Notepad/ , http://localhost:8081/Notepad/cesiummyexample.html , http://localhost:8081/Notepad/hello , http://localhost :8081/Notepad/hello?name=Notepad-SpringBootMaven , the result is shown in the figure below.
3.1.2 Create a new Spring Boot project managed by Gradle and run it as a jar package
To use the online Spring Initializr to create a new Gradle
management Spring Boot
project, you need to make the following settings, Project selection Gradle Project
, Language selection Java
, Spring Boot version selection 2.5.6
, Group setting com.example.test
, Artifact setting demogradlespringboot
, Name setting demogradlespringboot
, Description setting Demo project for Spring Boot
, Package name setting com.example.test.demogradlespringboot
, Packing packaging method selection Jar
, Java version selection 8
, Dependencies selection on the right Spring Web
and click the bottomGenerate, the compressed package file corresponding to the project will be downloadeddemogradlespringboot.zipand unzip to a folder.
The demogradlespringboot project folder is shown in the above figure, use Notepad Notepad
to open the file under src\main\java\com\example\test\demogradlespringboot Modify the code as shown below, and then in the project root directoryDemogradlespringbootApplication.java
DemogradlespringbootApplication.java
F:\workspace\MydemoSpringBoot\demogradlespringbootStart the cmd command line window and enter the command gradlew bootRun
to start the project.
DemogradlespringbootApplication.java
package com.example.test.demogradlespringboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class DemogradlespringbootApplication {
public static void main(String[] args) {
SpringApplication.run(DemogradlespringbootApplication.class, args);
}
@GetMapping("/hello")
public String hello(@RequestParam(value = "name", defaultValue = "World") String name)
{
return String.format("Hello %s!", name);
}
}
After starting and running, since GRADLE_USER_HOME
the value of the system environment variable has been setD:\program files\gradle-7.2\GradleRepository.gradlewrapper
, so the project will automatically create new and three folders under this folder , among which the folder will automatically download gradle-7.2 , the folder will store the bin file of gradle , and .tmp
the folder will store the jar package files that the project depends on . After the project starts successfully , open Google Chrome and visit http://localhost:8080/ , http://localhost:8080/hello , http://localhost:8080/hello?name=notepad456 in turn , the result is shown in the figure below, Then use the keyboard + and enter in the cmd window to end the operation.caches
wrapper
.tmp
caches
CtrlCY
In order to modify the port number port, you can edit the files under the src\main\resources folder, the content is as follows:application.properties
server.port=8082
server.servlet.context-path=/Notepad
At the same time, in order to modify the default page, you can create a new file (default page) and file (custom access page) under the src\main\resources\static folder . document contentindex.html
cesiummyexample.html
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>index.html</title>
</head>
<body>
Hello Spring Boot!
</body>
</html>
cesiummyexample.html
document content
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Include the CesiumJS JavaScript and CSS files -->
<script src="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Cesium.js"></script>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
<div id="cesiumContainer"></div>
<script>
// Your access token can be found at: https://cesium.com/ion/tokens.
// Replace `your_access_token` with your Cesium ion access token.
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4ZDdhNmRjMC0yNGMxLTRlYWItYjU5Ny1jZjJjZWIyNWI2YmIiLCJpZCI6NzY2Niwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU1MDExMjI4NH0.e_LkplBoPjo_fSqLsGAb97ypotS0G5tMHJoSxLkqyUw';
// Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
const viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider: Cesium.createWorldTerrain()
});
// Add Cesium OSM Buildings, a global 3D buildings layer.
const buildingTileset = viewer.scene.primitives.add(Cesium.createOsmBuildings());
// Fly the camera to San Francisco at the given longitude, latitude, and height.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-122.4175, 37.655, 400),
orientation : {
heading : Cesium.Math.toRadians(0.0),
pitch : Cesium.Math.toRadians(-15.0),
}
});
</script>
</div>
</body>
</html>
Then use the cmd command line window to start the project in the root directory of the project and then exit , you can use gradlew build
the command to type the project intojar package, and then use the command to run the project in the cmd windowjava -jar xxx.jar
, which is simple, trouble-free and highly portable.
At this time, use Google Chrome to visit http://localhost:8082/Notepad/ , http://localhost:8082/Notepad/cesiummyexample.html , http://localhost:8082/Notepad/hello , http://localhost :8082/Notepad/hello?name=Notepad-SpringBootGradle , the result is shown in the figure below.
3.2 Using Eclipse as IDE
3.2.1 Eclipse configuration Java
Go to the Eclipse official website to download the eclipse-jee-2021-09-R-win32-x86_64.zip file without installationD:\program files\eclipse2021
, and extract it to a folder here . You can create a new workspace folder
in the folder, and then double-click to run it. After starting , select the workspace as the previously customized workspace folder, then create a new project , configure , create a new class under the new package , and in the main function output fromD:\program files\eclipse2021
myworkspace
eclipse.exe
Eclipse
Java
HelloWorld
JRE运行时
com
Java
hello
hello,world!
Test whether the environment configuration of the Java compiler in Eclipse is successful, if the operation is successful, Console
the console will output text information.
3.2.2 Eclipse configuration Maven
3.2.3 Eclipse Deploy Gradle
Click in Eclipse
the menu bar , enter the Preference window, click Gradle on the left, and select the local installation directory on the right :Windows
Preference
Gradle
Local installation directory
D:\program files\gradle-7.2, Gradle
the user library directory Gradle user home
:D:\program files\gradle-7.2\GradleRepository.gradleAnd Java
the installation directory Java home
:D:\Program Files (x86)\Java\jdk1.8.0_221, click Apply
Apply.
3.2.4 Eclipse deployment Spring Tools
In order to Eclipse
install Spring
plugins in there are two options:method oneIt is directly selected in the Eclipse
upper menu bar . After entering the window and searching , click on the right side of the first one in the lower result list , and keep clicking Next until the installation is complete and prompts to restart ;Help
Eclipse MarketPlace
Eclipse MarketPlace
spring tools
Install
eclipse
way twoAfter downloading from the Spring Tools page, go to Eclipse to configure the plug-in. (Note: The first method of installation is introduced and recommended here , which is simple and direct)
3.2.5 Create a new Spring Boot project in Eclipse
3.2.5.1 Eclipse creates a new Spring Boot project managed by Maven
After the installation is complete, you can see the Spring Boot option in the new project using Eclipse.
Run as
Java Application
You can choose or choose here Spring Boot App
. After the actual test, the running effect is the same on the console, and it can be started.
After opening http://localhost:8080 with a browser , the following page is created successfully; at the same time, accessing http://localhost:8080/hello will print Hello World!
; accessing http://localhost:8080/hello?name=csdn123 will printHello csdn123!
If you want to modify Tomcat
the access port number (default 8080), you need to application.properties
edit the file, or you can change the suffix name yml
to edit it. Also need to pom.xml
add maven-resources-plugin
dependencies in.
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
</dependency>
application.properties
The content of the file is as follows:
server.port=8081
server.servlet.context-path=/csdn
application.yml
The content of the file is as follows:
server:
#端口号
port: 8081
#项目名,如果不设定,默认是 /
servlet:
context-path: /csdn
After saving and running, you can see that the port number port and context path have been successfully modified, and then visit the following three links in the browser: http://localhost:8081/csdn/ , http://localhost:8081/ csdn/hello , http://localhost:8081/csdn/hello?name=csdn123
If you want to make a welcome page, you resources
can static
create a new index.html
file in the following, the content of the file is as follows:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>index.html</title>
</head>
<body>
Hello Spring Boot!
</body>
</html>
Then with a curious attitude, I tried to create a new cesiummyexample.html
file under the static folder, and found that I could visit http://localhost:8081/csdn/cesiummyexample.htmlSpringBoot
in the browser after startup , which is really good.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Include the CesiumJS JavaScript and CSS files -->
<script src="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Cesium.js"></script>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
<div id="cesiumContainer"></div>
<script>
// Your access token can be found at: https://cesium.com/ion/tokens.
// Replace `your_access_token` with your Cesium ion access token.
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4ZDdhNmRjMC0yNGMxLTRlYWItYjU5Ny1jZjJjZWIyNWI2YmIiLCJpZCI6NzY2Niwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU1MDExMjI4NH0.e_LkplBoPjo_fSqLsGAb97ypotS0G5tMHJoSxLkqyUw';
// Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
const viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider: Cesium.createWorldTerrain()
});
// Add Cesium OSM Buildings, a global 3D buildings layer.
const buildingTileset = viewer.scene.primitives.add(Cesium.createOsmBuildings());
// Fly the camera to San Francisco at the given longitude, latitude, and height.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-122.4175, 37.655, 400),
orientation : {
heading : Cesium.Math.toRadians(0.0),
pitch : Cesium.Math.toRadians(-15.0),
}
});
</script>
</body>
</html>
3.2.5.2 Eclipse creates a SpringBoot project managed by Gradle
Open it , select File->New->OtherEclipse
in the menu bar , and a pop-up window will pop up, select the next one and click , enter the project name in the window , and then select the type Type , Packaging selection , Java Version selection , Language language selection , and the rest You can customize it, then click to pop up the New Spring Starter Project Dependencies window, select the Spring Boot version ( note that it is not recommended to choose the SNAP-SHOT version), check it and click it. Note: In fact, in essence, the property setting of the new project is ultimately to piece together a URL download link of the eclipse_SpringBoot2 project to obtain the set Spring Boot project , because the root is essentially fromSelect a wizard
Spring Boot
Spring Starter Project
Next
New Spring Starter Project
eclipse_SpringBoot2
Gradle Project
Jar
8
Java
Next
2.5.6
Web
Spring Web
Finish
Eclipse
Spring Boot
Spring Initializer to download. But it is still Eclipse
more convenient and faster to use here.
https://start.spring.io/starter.zip?name=eclipse_SpringBoot2&groupId=my.test&artifactId=eclipse_SpringBoot2&version=0.0.1-SNAPSHOT&description=Demo+project+for+Spring+Boot&packageName=my.test.mydemo&type=gradle-project&packaging=jar&javaVersion=1.8&language=java&bootVersion=2.5.6&dependencies=web
After starting and running, open the browser and visit http://localhost:8080/ , http://localhost:8080/hello , http://localhost:8080/hello?name=csdn456 in turn , and you can see the following results to Gradle
manage Spring Boot
the project Created and run successfully.
If you want to modify the port number port
and default page, you can application.properties
edit the file, and create a new file and cesiummyexample.html file in the folder under src/main/resources , and then start it again. document:static
index.html
application.properties
server.port=8082
server.servlet.context-path=/CSDN
index.html file:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Welcome to CSDN</title>
</head>
<body>
Hello,I'm CSDN! Welcome you!
</body>
</html>
Cesiummyexample.html file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Include the CesiumJS JavaScript and CSS files -->
<script src="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Cesium.js"></script>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
<div id="cesiumContainer"></div>
<script>
// Your access token can be found at: https://cesium.com/ion/tokens.
// Replace `your_access_token` with your Cesium ion access token.
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4ZDdhNmRjMC0yNGMxLTRlYWItYjU5Ny1jZjJjZWIyNWI2YmIiLCJpZCI6NzY2Niwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU1MDExMjI4NH0.e_LkplBoPjo_fSqLsGAb97ypotS0G5tMHJoSxLkqyUw';
// Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
const viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider: Cesium.createWorldTerrain()
});
// Add Cesium OSM Buildings, a global 3D buildings layer.
const buildingTileset = viewer.scene.primitives.add(Cesium.createOsmBuildings());
// Fly the camera to San Francisco at the given longitude, latitude, and height.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-122.4175, 37.655, 400),
orientation : {
heading : Cesium.Math.toRadians(0.0),
pitch : Cesium.Math.toRadians(-15.0),
}
});
</script>
</body>
</html>
http://localhost:8082/CSDN
http://localhost:8082/CSDN/hello
http://localhost:8082/CSDN/hello?name=csdn456
http://localhost:8082/CSDN/cesiummyexample.html
3.3 Using VSCode as IDE
Go to the VSCode official website to download the Windows x64-bit installation package VSCodeUserSetup-x64-1.61.2.exe , double-click to install it directly.
3.3.1 VSCode configuration Java
Open Visual Studio Code
, click the extension (Ctrl+Shift+X) under View in the menu bar to pop up the extension search box to enter Java Extension Pack
, find the search result and install it.
In order to configure the Java runtime environment in VSCode, click the setting icon in the lower left corner of VSCode to enter the settings, enter in the upper text box to open the java.configuration.runtimes
file settings.json
, edit the content as follows:
enter to Java: Create New Project
create a Java project, then click No Build Tools
, select the workspace folder, the project After entering the name, FirstJavaApplication
press Enter to confirm.
3.3.2 VSCode configuration Maven
First click on VSCode
the extension under View in the menu bar. After opening the extension window, Maven for Java
install the Maven plug-in by searching
and then click VSCode
the setting icon in the lower left corner to enter the setting. After typing in the text box above, java.configuration.maven
click Java to configure the global settings and user settings on the right. Just point to the files in the folder under the local installation directory (Maven
Maven
conf
settings.xml
D:\program files\apache-maven-3.8.3\conf\settings.xml)。
3.3.3 VSCode configuration Gradle
First click VSCode
the extension under View in the menu bar, open the extension window, and Gradle Extension Pack
install the Gradle plug-in by searching
3.3.4 VSCode configuration Spring Tools
First click on VSCode
the extension under View in the menu bar, open the extension window, and Spring Boot Extension Pack
install the Spring Boot plug-in by searching
3.3.5 Create Spring Boot project in VSCode
3.3.5.1 VSCode creates a Spring Boot project managed by Maven
Open it VSCode
, click View All Commands in Help in the menu bar , enter in the command box and press Enter, and then set the properties of the project: Select Spring Boot Version , select Project Language , enter Group Id and press Enter, and enter Artifact Id Press Enter, select Packing Type , Java Version , Choose Dependencies , finally select the workspace and confirm, wait for the project initialization to complete . After the project initialization is completed, edit the src->main->java->com.example.mytest.demospringbootmaven as shown in the figure below . The edited code is as follows, and then right-click to run.Spring Initializr: Create a Maven Project
2.5.6
Java
com.example.mytest
demospringmaven
Jar
8
Spring Web
D:\program files\Microsoft VS Code\myworkspace
DemospringbootmavenApplication.java
Run Java
package com.example.mytest.demospringbootmaven;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class DemospringbootmavenApplication {
public static void main(String[] args) {
SpringApplication.run(DemospringbootmavenApplication.class, args);
}
@GetMapping("/hello")
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
return String.format("Hello %s!", name);
}
}
You can see that the Spring Boot project runs successfully. At this time, open Google Chrome and visit http://localhost:8080/ , http://localhost:8080/hello , http://localhost:8080/hello?name=vscode123 , The result is shown in the figure below.
If you want to modify the port number port
and default page, you can application.properties
edit the file, and create a new file and file under the folder under src/main/resources , and then start the operation again. document:static
index.html
cesiummyexample.html
application.properties
server.port=8081
server.servlet.context-path=/VSCode
index.html
document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome to VSCode</title>
</head>
<body>
Hello,I'm MavenSpringBoot Application in VSCode!
</body>
</html>
cesiummyexample.html
document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Include the CesiumJS JavaScript and CSS files -->
<script src="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Cesium.js"></script>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
<div id="cesiumContainer"></div>
<script>
// Your access token can be found at: https://cesium.com/ion/tokens.
// Replace `your_access_token` with your Cesium ion access token.
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4ZDdhNmRjMC0yNGMxLTRlYWItYjU5Ny1jZjJjZWIyNWI2YmIiLCJpZCI6NzY2Niwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU1MDExMjI4NH0.e_LkplBoPjo_fSqLsGAb97ypotS0G5tMHJoSxLkqyUw';
// Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
const viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider: Cesium.createWorldTerrain()
});
// Add Cesium OSM Buildings, a global 3D buildings layer.
const buildingTileset = viewer.scene.primitives.add(Cesium.createOsmBuildings());
// Fly the camera to San Francisco at the given longitude, latitude, and height.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-122.4175, 37.655, 400),
orientation : {
heading : Cesium.Math.toRadians(0.0),
pitch : Cesium.Math.toRadians(-15.0),
}
});
</script>
</body>
</html>
After the project starts, the browser visits http://localhost:8081/VSCode/
http://localhost:8081/VSCode/cesiummyexample.html
http://localhost:8081/VSCode/hello
http://localhost:8081/VSCode /hello?name=vscode456
3.3.5.2 VSCode creates a Spring Boot project managed by Gradle
Open it VSCode
, click View All Commands in Help in the menu bar , enter in the command box and press Enter, and then set the properties of the project: Select Spring Boot Version , select Project Language , enter Group Id and press Enter, and enter Artifact Id Press Enter, select Packing Type , Java Version , Choose Dependencies , finally select the workspace and confirm, wait for the project initialization to complete . After the project initialization is complete , you can use VS to reopen the demospringgradle folder and edit it under src->main->java->com.example.mytest.demospringbootgradle as shown in the figure below. The edited code is as follows, and then right-click to run .Spring Initializr: Create a Gradle Project
2.5.6
Java
com.example.mytest
demospringgradle
Jar
8
Spring Web
D:\program files\Microsoft VS Code\myworkspace
DemospringgradleApplication.java
Run Java
package com.example.mytest.demospringgradle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class DemospringgradleApplication {
public static void main(String[] args) {
SpringApplication.run(DemospringgradleApplication.class, args);
}
@GetMapping("/hello")
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
return String.format("Hello %s!", name);
}
}
You can see that the Spring Boot project runs successfully. At this time, open Google Chrome and visit http://localhost:8080/ , http://localhost:8080/hello , http://localhost:8080/hello?name=vscode- gradle123 , the result is shown in the figure below.
If you want to modify the port number port
and default page, you can application.properties
edit the file, and create a new file and file under the folder under src/main/resources , and then start the operation again. document:static
index.html
cesiummyexample.html
application.properties
server.port=8082
server.servlet.context-path=/VSCode
index.html
document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome to VSCode</title>
</head>
<body>
Hello,I'm GradleSpringBoot Application in VSCode!
</body>
</html>
cesiummyexample.html
document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Include the CesiumJS JavaScript and CSS files -->
<script src="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Cesium.js"></script>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
<div id="cesiumContainer"></div>
<script>
// Your access token can be found at: https://cesium.com/ion/tokens.
// Replace `your_access_token` with your Cesium ion access token.
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4ZDdhNmRjMC0yNGMxLTRlYWItYjU5Ny1jZjJjZWIyNWI2YmIiLCJpZCI6NzY2Niwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU1MDExMjI4NH0.e_LkplBoPjo_fSqLsGAb97ypotS0G5tMHJoSxLkqyUw';
// Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
const viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider: Cesium.createWorldTerrain()
});
// Add Cesium OSM Buildings, a global 3D buildings layer.
const buildingTileset = viewer.scene.primitives.add(Cesium.createOsmBuildings());
// Fly the camera to San Francisco at the given longitude, latitude, and height.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-122.4175, 37.655, 400),
orientation : {
heading : Cesium.Math.toRadians(0.0),
pitch : Cesium.Math.toRadians(-15.0),
}
});
</script>
</body>
</html>
After the project starts, the browser visits http://localhost:8082/VSCode/
http://localhost:8082/VSCode/
http://localhost:8082/VSCode/hello
http://localhost:8082/VSCode/hello? name=vscode-gradle456
3.4 Using IDEA as IDE
Go to the IDEA official website to download the trial version or purchase the professional version for installation to experience more complete Java Web Enterprise Edition development functions.
3.4.1 IDEA Deploy Java
Open IDEA
, and then click the next in the lower right corner Configure
, Structure for New Projects
a pop-up Project Sturcture for New Projects
window, click on the left side of the window SDKs
and click in the middle +to select JDK
the directoryD:\Program Files (x86)\Java\jdk1.8.0_221, you can see Classpath
that there is a jar package file in the corresponding JDK directory .
3.4.2 IDEA Deployment Maven
Open it IDEA
, and then click in the lower right corner Configure
to Settings
pop up a window, select Build Tools under Build, Execution, Deployment on Settings for New Projects
the left side of the window , and set the installation directory on the right side toMaven
Maven
Maven home directory
D:/program files/apache-maven-3.8.3 , the user settings file User setting file
isD:\program files\apache-maven-3.8.3\conf\settings.xml, the local Maven
library directory Local repository
is set toD:\program files\apache-maven-3.8.3\repository, click the lower right corner Apply
-> OK to apply the settings.
3.4.3 IDEA Deployment Gradle
Open it IDEA
, and then click in the lower right corner Configure
to Settings
pop up a window, select Build Tools under Build, Execution, DeploymentSettings for New Projects
on the left side of the window , and set the local user library directory toGradle
Gradle
Gradle user home
D:\program files\gradle-7.2\GradleRepository.gradle, click the lower right corner Apply
-> OK to apply the settings.
3.4.4 IDEA Deployment Spring Tools
Open it IDEA
, and then click in the lower right corner Configure
, Plugins
a pop-up window, enter Spring ToolsPlugins
in the search box and click Install , and then you can see under Installed , and other extensions have been installed.Install
Spring Tools
Maven
Gradle
3.4.5 IDEA creates a Spring Boot project
3.4.5.1 IDEA creates a Spring Boot project managed by Maven
Open it IDEA
, click to Create New Project
create a new project, and a pop-up New Project
window will pop up, select the left side, and then select the local Project SDKSpring Initializer
on the right side by default , select the default URL https://start.spring.io at the bottom and click . In the New Project window, set some properties of the project (such as Group customization, Artifact customization, Type selection , Language selection , Packing packaging method selection , Java Version selection , Version customization filling, Name writing , Description customization, Package Package name is automatically generated) and click , and then click after selecting DependenciesJava JDK 1.8
Next
Spring Initializer Project Settings
Maven Project
Java
Jar
8
demomavenspring
Next
Web
Spring Web
Next
, and finally check the project name Project Name
, project location , and module settings Project Location
below , and then click . After the project is created, as shown in the figure below, inModule Settings
Finish
src-main-java-com.example.demomavenspringDemomavenspringApplication.java
Right-click to run Run 'DemomavenspringApplication' after editing the code below , and then Console
see the project running and starting results in the console.
package com.example.demomavenspring;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class DemomavenspringApplication {
public static void main(String[] args)
{
SpringApplication.run(DemomavenspringApplication.class, args);
}
@GetMapping("/hello")
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
return String.format("Hello %s!", name);
}
}
At this time, open Google Chrome and visit http://localhost:8080 , http://localhost:8080/hello , http://localhost:8080/hello?name=IDEAMavenSpring in turn , and the result is shown in the figure below.
If you want to modify the port number port
and default page, you can application.properties
edit the file, and create a new file and file under the folder under src/main/resources , and then start the operation again. document:static
index.html
cesiummyexample.html
application.properties
server.port=8081
server.servlet.context-path=/IDEA
index.html
document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome to IDEA</title>
</head>
<body>
Hello,I'm MavenSpringBoot Application in IDEA!
</body>
</html>
cesiummyexample.html
document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Include the CesiumJS JavaScript and CSS files -->
<script src="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Cesium.js"></script>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
<div id="cesiumContainer"></div>
<script>
// Your access token can be found at: https://cesium.com/ion/tokens.
// Replace `your_access_token` with your Cesium ion access token.
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4ZDdhNmRjMC0yNGMxLTRlYWItYjU5Ny1jZjJjZWIyNWI2YmIiLCJpZCI6NzY2Niwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU1MDExMjI4NH0.e_LkplBoPjo_fSqLsGAb97ypotS0G5tMHJoSxLkqyUw';
// Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
const viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider: Cesium.createWorldTerrain()
});
// Add Cesium OSM Buildings, a global 3D buildings layer.
const buildingTileset = viewer.scene.primitives.add(Cesium.createOsmBuildings());
// Fly the camera to San Francisco at the given longitude, latitude, and height.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-122.4175, 37.655, 400),
orientation : {
heading : Cesium.Math.toRadians(0.0),
pitch : Cesium.Math.toRadians(-15.0),
}
});
</script>
</body>
</html>
After the project starts, the browser visits http://localhost:8081/IDEA/
http://localhost:8081/IDEA/cesiummyexample.html
http://localhost:8081/IDEA/hello
http://localhost:8081/IDEA /hello?name=IDEAmavenSpringBoot
3.4.5.2 IDEA creates a Spring Boot project managed by Gradle
Open it IDEA
, click to Create New Project
create a new project, and a pop-up New Project
window will pop up, select the left side, and then select the local Project SDKSpring Initializer
on the right side by default , select the default URL https://start.spring.io at the bottom and click . In the New Project window, set some properties of the project (such as Group customization, Artifact customization, Type selection , Language selection , Packing packaging method selection , Java Version selection , Version customization filling, Name writing , Description customization, Package Package name is automatically generated) and click , and then click after selecting DependenciesJava JDK 1.8
Next
Spring Initializer Project Settings
Gradle Project
Java
Jar
8
demogradlespring
Next
Web
Spring Web
Next
, and finally check the project name Project Name
, project location , and module settings Project Location
below , and then click . After the project is created, as shown in the figure below, inModule Settings
Finish
src-main-java-com.example.demomavenspringDemogradlespringApplication.java
After editing the code below , right-click to run Run 'DemogradlespringApplication', and then Console
see the project running and starting results in the console.
At this time, open Google Chrome and visit http://localhost:8080 , http://localhost:8080/hello , http://localhost:8080/hello?name=IDEAGradleSpring in turn , and the result is shown in the figure below.
If you want to modify the port number port
and default page, you can application.properties
edit the file, and create a new file and file under the folder under src/main/resources , and then start the operation again. document:static
index.html
cesiummyexample.html
application.properties
server.port=8082
server.servlet.context-path=/IDEA
index.html
document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome to IDEA</title>
</head>
<body>
Hello,I'm GradleSpringBoot Application in IDEA!
</body>
</html>
cesiummyexample.html
document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Include the CesiumJS JavaScript and CSS files -->
<script src="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Cesium.js"></script>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.86/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
<div id="cesiumContainer"></div>
<script>
// Your access token can be found at: https://cesium.com/ion/tokens.
// Replace `your_access_token` with your Cesium ion access token.
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4ZDdhNmRjMC0yNGMxLTRlYWItYjU5Ny1jZjJjZWIyNWI2YmIiLCJpZCI6NzY2Niwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU1MDExMjI4NH0.e_LkplBoPjo_fSqLsGAb97ypotS0G5tMHJoSxLkqyUw';
// Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
const viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider: Cesium.createWorldTerrain()
});
// Add Cesium OSM Buildings, a global 3D buildings layer.
const buildingTileset = viewer.scene.primitives.add(Cesium.createOsmBuildings());
// Fly the camera to San Francisco at the given longitude, latitude, and height.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-122.4175, 37.655, 400),
orientation : {
heading : Cesium.Math.toRadians(0.0),
pitch : Cesium.Math.toRadians(-15.0),
}
});
</script>
</body>
</html>
After the project starts, the browser visits http://localhost:8082/IDEA/
http://localhost:8082/IDEA/cesiummyexample.html
http://localhost:8082/IDEA/hello
http://localhost:8082/IDEA /hello?name=gradleSpring
4、Spring Boot CLI
Spring Boot CLI
is a command-line tool that can be used to quickly develop Spring
applications, allows running Groovy
scripts, and can use familiar similar Java
syntax without much boilerplate code to bootstrap a new project or write custom commands for it. Spring Boot CLI 2.6.0 download address , unzip the file and open the INSTALL.txt file, prompting that Java needs to be installed, you can enter it in the cmd windowjava -version
to test whether the Java environment configuration is complete.
Then right click on the computer->Properties->Advanced System Settings->Environment Variables, create a new system environment variable SPRING_HOME, set its value toD:\Program Files (x86)\spring-2.6.0-SNAPSHOT, and then find under the system environment variable Path
, add it to it %SPRING_HOME%\bin
and confirm.
Refer to the Spring Boot CLI documentation to learn common commands.