eclipse 选择不能在任何服务器上运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44024803/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The selection cannot be run on any server
提问by Sumit
I am trying to learn a bit about spring boot application. Below is the pom.xml file. The problem is that when I try to run the application on server I get the message The selection cannot be run on server
. Not sure why this is happening.
我正在尝试了解一些有关 Spring Boot 应用程序的知识。下面是 pom.xml 文件。问题是,当我尝试在服务器上运行应用程序时,我收到了消息The selection cannot be run on server
。不知道为什么会这样。
I have checked few similar stack overflow questions listed below "The selection cannot be run on any server"and Eclipse Maven Spring: Server Error when I try to Run As Server (Tomcat 7)but couldn't get a solution.
我检查了下面列出的几个类似的堆栈溢出问题 “选择不能在任何服务器上运行”和Eclipse Maven Spring:当我尝试作为服务器运行时的服务器错误 (Tomcat 7)但无法获得解决方案。
There are no errors or warnings in the problems tab of STS. Also I have configured STS to use Apache tomcat version 9.
STS 的问题选项卡中没有错误或警告。此外,我已将 STS 配置为使用 Apache tomcat 版本 9。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.blog</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Please suggest what has to be done for running this application on server
请建议在服务器上运行此应用程序必须做什么
回答by Abdullah Khan
What you are dealing with is a Spring boot
application which has an embedded battle testedTomcat
server.
您正在处理的是一个Spring boot
具有嵌入式战斗测试Tomcat
服务器的应用程序。
To run your application you have to run it as a Java Application
or a Spring Boot App
.
要运行您的应用程序,您必须将其作为 aJava Application
或Spring Boot App
.
Check out thisand thisto find out how to deploy Spring boot
app as a war.
回答by Dan Newton
Taking a real stab in the dark as I can't try the code out myself at the moment, but it could be that you just need to run the file marked with @SpringBootApplication instead of looking for running via the server option. Thats how I normally do it, but I use Intellij so maybe its slightly different.
在黑暗中进行真正的尝试,因为我目前无法自己尝试代码,但可能是您只需要运行标有 @SpringBootApplication 的文件,而不是通过服务器选项寻找运行。这就是我通常的做法,但我使用 Intellij,所以可能略有不同。
回答by Giggs
Instead of Running the application as Java Application , Run the application as Spring Boot Application
不是将应用程序作为 Java 应用程序运行,而是将应用程序作为 Spring Boot 应用程序运行