Offer arrives, dig friends to pick up! I am participating in the 2022 Spring Recruitment Check-In Event, click to view the event details .
The Fullstack-type development space comes with several out-of-the-box extensions that are used to develop CAP applications, such as built-in CDS tools.
Open a new terminal window:
Enter the command cd projects/
:
Run the following command line:
mvn -B archetype:generate -DarchetypeArtifactId=cds-services-archetype -DarchetypeGroupId=com.sap.cds \
-DarchetypeVersion = 1.17.0
-DgroupId = com.sap.cap -DartifactId = products-service -Dpackage = com.sap.cap.productsservice
Below is an explanation of this parameter.
- archetype:generate: The full name is org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate, where archetype means archetype.
Generate a new project from the prototype, and update the actual project if a partial prototype is used. If the project is fully generated, it is generated in the directory corresponding to its artifactId. If the project is updated with a partial prototype, it is done in the current directory.
Reference link .
After running, use the prototype to generate the project skeleton:
Open workspace:
Among them, db stores database-related resources, and srv folder stores Java-related codes.
CAP applications use Core Data Services (CDS) to describe:
entity definitons
Data structures using entity definitions ( )- Use services to define how to use data structures
Create a new file in the srv folder and name it ``:
Define Products
an :
service AdminService {
entity Products {
key ID : Integer;
title : String(111);
descr : String(1111);
}
}
复制代码
Execute the mvn clean install command:
Make sure to see BUILD SUCCESSFUL
the message.
When we used the command line to mvn -B archetype:generate
create , it was automatically generated Application.java
:
The Application.java file can be opened directly with ctrl + p:
mvn clean spring-boot:run
Start the template application using the command line :
Prompt that there is an application listening on port 8080. Click Expose and Open
.
Port 8080 has been exposed and listening services can be accessed externally. To see the mapped URL, use the "Ports: Preview" command.
Open the command panel:
Execute to ports:preview
view url:
I saw the url of the application:
workspaces-ws-pdwk4-app1.us10.trial.applicationstudio.cloud.sap
The naming convention for this url:
The highlighted id is the workspace id: