rest api如何创建_REST:创建注册应用程序

rest api如何创建

REST:创建注册应用程序 (REST: Creating the Registration Application)

The prerequisites for developing the registration application are:

开发注册应用程序的前提条件是:

  1. Maven configured on the machine.

    在机器上配置了Maven。
  2. Eclipse (IDE) installed on the machine.

    在机器上安装了Eclipse(IDE)。
  3. Apache Tomcat Server installed in the machine.

    在机器上安装了Apache Tomcat Server。

发展步骤 (Steps of Development)

  1. Choose the directory where you want to keep the files related to this application.

    选择您要保留与此应用程序相关的文件的目录。
  2. cd {your directory} → run the below mentioned command in the command prompt. cd {your directory} →在命令提示符下运行以下提到的命令。
    mvn archetype:generate -DgroupId=com.rest.tutorials -DartifactId=RegistrationApp
    -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
    
    

    Make sure that Maven is setup before running the above command. This command will create the web application structure in your directory and pom.xml file. This pom.xml file is the metadata of your application.

    运行上述命令之前,请确保已安装Maven。 此命令将在目录和pom.xml文件中创建Web应用程序结构。 此pom.xml文件是您的应用程序的元数据。

    Your pom.xml will look something like this,

    您的pom.xml看起来像这样,

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.rest.tutorials</groupId>
      <artifactId>RegistrationApp</artifactId>
      <packaging>war</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>RegistrationApp Maven Webapp</name>
      <url>http://maven.apache.org</url>
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <finalName>RegistrationApp</finalName>
      </build>
    </project>


  3. pom.xml file, just like the Junit dependency is added. pom.xml文件中添加Jersey依赖项,就像添加了Junit依赖项一样。
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-moxy</artifactId>
        <version>2.25.1</version>
    </dependency> 
       <dependency>
       <groupId>org.glassfish.jersey.core</groupId>
       <artifactId>jersey-server</artifactId>
       <version>2.22.1</version>
    </dependency>
    <dependency>
       <groupId>org.glassfish.jersey.containers</groupId>
       <artifactId>jersey-container-servlet</artifactId>
       <version>2.22.1</version>
    </dependency>


  4. mvn eclipse:eclipse mvn eclipse:eclipse

    This will generate a .classpath and a .project file so that you can import this project into the eclipse.

    这将生成一个.classpath和.project文件,以便您可以将该项目导入eclipse中。

    Creating the Registration Application



  5. The project structure should look like this in the eclipse now.

    现在,项目结构在Eclipse中应该看起来像这样。

翻译自: https://www.studytonight.com/rest-web-service/creating-the-registration-application

rest api如何创建

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值