随笔 - 607,  文章 - 169,  评论 - 2,  阅读 - 21万

 


0    课程地址

https://coding.imooc.com/lesson/201.html#mid=12745

 

1    重点关注

1.1    本节内容

使用main主线程启动dubbo服务

 

1.2    已解决问题

本节service没有依赖成功api,

经查询可能是sts版本问题,没有重新加载的选项(mavenrepositories没有rebuild index选项,并且仓库不可修改在c盘,后边有时间重新换个版本的试试)

 

答复:

问题已解决,需要在父项目(父项目的pom文件有modules),右键run as ->maven install即可生成jar包

<modules>
        <module>imooc-dubbo-common</module>
        <module>imooc-dubbo-item-api</module>
        <module>imooc-dubbo-item-service</module>
        <module>imooc-dubbo-order-api</module>
        <module>imooc-dubbo-order-service</module>
        <module>imooc-dubbo-web</module>
    </modules>

 

 

 

2    课程内容

 

 

 

3    Coding

3.1    使用tomcat启动dubbo服务

  • 主要改造点:

涉及父项目,common项目,service和api项目共4个,

涉及

a  将启动的main方法写到service子项目,main方法加载主配置文件

b  主配置文件将所有配置文件聚合到一起

 

 

  • a  将启动的main方法写到service子项目,main方法加载主配置文件

ItemApplication

复制代码
package com.imooc.item.starter;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ItemApplication {

    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                new String[] {"classpath:spring/spring-context.xml"});
        context.start();
        // press any key to exit
        System.in.read();
    }

}
复制代码

 

 

  • b  主配置文件将所有配置文件聚合到一起

spring-context.xml

复制代码
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd">
        
    <import resource="classpath:spring/applicationContext-dao.xml"/>
    <import resource="classpath:spring/applicationContext-dubbo-provider.xml"/>
    <import resource="classpath:spring/applicationContext-service.xml"/>
    <import resource="classpath:spring/applicationContext-transaction.xml"/>
    
</beans>
复制代码

 

 

  • c  启动main方法即可














posted on   菜鸟乙  阅读(11)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
历史上的今天:
2019-04-23 Spring课程 Spring入门篇 6-3 ProxyFactoryBean及相关内容(下)
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

点击右上角即可分享
微信分享提示

目录导航