操作步骤

  1. 新建一个springboot工程orchid

  2. 新建一个vue项目并成功打包,可以参考https://www.cnblogs.com/ants_double/p/13391211.html

  3. 添加必要的依赖

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-thymeleaf</artifactId>
            </dependency>
    
  4. 添加controller入口

    @Controller()
    @RequestMapping("/")
    public class IndexController {
        @GetMapping("home")
        public ModelAndView index(){
            ModelAndView mv =  new ModelAndView("index");
            return mv;
        }
    }
    
  5. 配置资源文件

    spring:
      thymeleaf:
        prefix: classpath:/templates/
        suffix: .html
        servlet:
          content-type: text/html
        mode: HTML
        cache: false
        encoding: utf-8
    
    
  6. 放入vue生成的包文件(使用默认路径)

    • static 文件夹放入 resources/static文件夹下
    • index.html放入resources/templates文件夹下
  7. 打包发布

    mvn package
    nohup java -jar ****.jar
    

源码

相关文章:

  • 2021-11-26
  • 2021-11-09
  • 2020-12-30
  • 2022-12-23
  • 2021-09-06
  • 2021-12-02
猜你喜欢
  • 2021-05-31
  • 2021-10-13
  • 2022-12-23
  • 2022-02-21
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
相关资源
相似解决方案