美文网首页
Solon 1.hello world

Solon 1.hello world

作者: 草编椅 | 来源:发表于2020-08-07 11:54 被阅读0次

    solon 是一个微型的WEB框架,采用 Handler + Context + 插件 架构。理念:尽可能简化配置,尽可能的启动快速,尽可能减少Ioc,Aop。

    一个 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

    希望会觉得简单...

    相关文章

      网友评论

          本文标题:Solon 1.hello world

          本文链接:https://www.haomeiwen.com/subject/fyyfbctx.html