java - spring boot多模块项目如打包?
巴扎黑
巴扎黑 2017-05-27 17:41:23
[Java讨论组]

我构建了一个简单的多模块的项目:
结构:

外层pom.xml如下

     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">
4.0.0

com.scum
demo-package
1.0-SNAPSHOT
pom


    demo-controller
    demo-service


    
        
            
            org.springframework.boot
            spring-boot-maven-plugin
        
            com.example.demo.DemoControllerApplication
            ZIP
        
        
            
                
                    repackage
                
                
                
            
        
    

`
web pom文件`

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0

com.example
demo-controller
0.0.1-SNAPSHOT
jar

demo-controller
Demo project for Spring Boot


    org.springframework.boot
    spring-boot-starter-parent
    1.5.3.RELEASE
     



    UTF-8
    UTF-8
    1.8



    
        org.springframework.boot
        spring-boot-starter-web
    

    
        org.springframework.boot
        spring-boot-starter-test
        test
    



    
        
            org.springframework.boot
            spring-boot-maven-plugin
        
    


`

能运行 打包报IndexService 不存在

package com.example.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@SpringBootApplication
@Controller
public class DemoControllerApplication {
    @Autowired
    private IndexService indexService;

    public static void main(String[] args) {
        SpringApplication.run(DemoControllerApplication.class, args);
    }

    @RequestMapping(value = "")
    @ResponseBody
    public String index(){
        return indexService.Index();
    }
}
巴扎黑
巴扎黑

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号