インタフェースプロジェクト単位のJavaの春ブーツ

新しいアイデアのMavenプロジェクト

カスタムグループ/ actifactId /バージョンで塗りつぶし

pom.xmlファイルで必要な依存関係を追加します。

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.2.RELEASE</version>
    </parent>
    <groupId>com.group</groupId>
    <artifactId>ljk</artifactId>
    <version>1.0.0</version>
    <name>first application</name>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.4.3</version>
            </plugin>
        </plugins>
    </build>
</project>

新しいクラスを作成した.java

package com.group.ljk;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@SpringBootApplication
public class App {
    @RequestMapping("/")
    public String index() {
        return "Welcome";
    }

    public static void main(String[] args){
        System.out.println("Hello World!");
        //启动spring项目
        SpringApplication.run(App.class,args);
    }
}

[OK]を、右スタート、デフォルトのポート8080
はlocalhost:8080

 

出版元の記事 ウォンの賞賛0 ビュー55

おすすめ

転載: blog.csdn.net/ljktc2010/article/details/104041554