[英]Run simple Rest Java hello world program
I am trying to run a simple Rest HelloWorld program as described in https://spring.io/guides/gs/rest-service/ . 我试图按照https://spring.io/guides/gs/rest-service/中的描述运行一个简单的Rest HelloWorld程序。 I have downloaded Spring and Maven and added the
MAVEN_HOME
and M3_HOME
environment variables. 我已经下载了Spring和Maven并添加了
MAVEN_HOME
和M3_HOME
环境变量。 I have run the mvn -v
command successfully in Windows command prompt. 我已经在Windows命令提示符下成功运行了
mvn -v
命令。 I browsed to the initial directory where the pom.xml
is located. 我浏览到
pom.xml
所在的初始目录。 Then I run mvn spring-root:run
but I get the following error: 然后我运行
mvn spring-root:run
但出现以下错误:
No plugin found for prefix 'spring-boot' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\\Users\\user.m2\\repository), central ( https://repo.maven.apache.org/maven2)] -> [Help 1]
在存储库[本地(C:\\ Users \\ user.m2 \\中)找不到当前项目和插件组[org.apache.maven.plugins,org.codehaus.mojo]中前缀为“ spring-boot”的插件。资料库),中央( https://repo.maven.apache.org/maven2)] -> [帮助1]
I have already searched for this error message on the internet but the suggestions are not solving my problem. 我已经在互联网上搜索了此错误消息,但是建议无法解决我的问题。 Am I forgetting something related to any installation?
我会忘记与任何安装相关的东西吗? Any idea or suggestion is highly appreciated.
任何想法或建议都将受到高度赞赏。
Oh, I realized now I had same issue in the past... 哦,我意识到现在我过去有同样的问题...
To address 讲话
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE:repackage (default) on project gs-rest-service: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE:repackage failed: Unable to find main class -> [Help 1]
You have to create Application
class (something annotated with @SpringBootApplication
) 您必须创建
Application
类(带有@SpringBootApplication
注释的类)
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
or skip tests mvn clean install -DskipTests
. 或跳过测试
mvn clean install -DskipTests
。
For mvnw spring-boot:run
I'm getting ConnectException right now... 对于
mvnw spring-boot:run
我现在正在获取ConnectException ...
Downloading https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
Exception in thread "main" java.net.ConnectException: Connection refused: connect
but it is very likely issue on my side... 但这很可能是我这方面的问题...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.