0
点赞
收藏
分享

微信扫一扫

Solon 1.hello world

夏侯居坤叶叔尘 2021-09-21 阅读 67
一个 hello world 项目
  • 1.新建一个空的 meven 项目:demo(我一般用IDEA)

  • 2.添加 dependency

<parent>
    <groupId>org.noear</groupId>
    <artifactId>solon-parent</artifactId>
    <version>1.0.9</version>
</parent>

<dependencies>
    <!-- solon 主框架 -->
    <dependency>
        <groupId>org.noear</groupId>
        <artifactId>solon</artifactId>
    </dependency>

    <!-- solon boot 插件(基于jlhttp包装,提供http服务) -->
    <dependency>
        <groupId>org.noear</groupId>
        <artifactId>solon.boot.jlhttp</artifactId>
    </dependency>
</dependencies>
  • 3.添加代码 src/main/java/webapp/App.java
package webapp;

import org.noear.solon.XApp;

public class App {
    public static void main(String[] args) {
        XApp app = XApp.start(App1.class, args);

        app.get("/", c -> c.output("hello world!"));
    }
}
  • 4.运行代码(两种方式)
    方式1.在IDEA里运行:对着App.java右键,点击:Run 'App.main()'
    方式2.打包为jar(大概130kb),命令行运行:java -jar demo.jar

  • 5.查看效果,在浏览器里打开:http://localhost:8080

希望会觉得简单...
举报

相关推荐

0 条评论