我创建了一个spring项目,更新了springmvc依赖 这是我的 pom.xml
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.6.2</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.0.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.0.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.0.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.0.8.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>
如你所见,我添加了 springmvc 并更新了 log4j 版本。 我的主要方法是这样的:
public class Starter {
public static void main(String[] args){
Properties properties = new Properties();
properties.setProperty("dubbo.spring.config", "classpath:applicationContext.xml");
ConfigUtils.addProperties(properties);
Main.main(args);
}
}
我运行了一下,没有报错
但是我可以通过端口80或8080访问该项目
如何解决?谢谢
最佳答案
Main.main是Dubbo容器中的一个方法,根据加载器配置,它应该加载SpringContainer
,SpringContainer将加载ClassPathXmlApplicationContext
并启动它。
所以这个问题取决于您的 applicationContext.xml
文件中的内容,如果您不想公开 Controller ,您可以修改 applicationContext.xml
以删除 Controller 或包扫描。
关于java - 如何访问dubbo Main中运行的spring mvc项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51567610/