[英]How to configure Spring Boot Run Configuratipon in IntelliJ
[英]How to run a spring boot app in intellij?
我想在 intellij idea 中运行一个演示 Spring Boot 应用程序,但出现错误:
Error:(3, 32) java: package org.springframework.boot does not exist
我的pom.xml
:
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.21.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>helloworld</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>helloworld</name>
<description>Hello World project for Spring Boot</description>
<properties>
<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-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
确保打开 pom.xml 而不是文件夹。 IntelliJ 会询问您是否要作为项目导入。 对这个问题回答是。 您始终可以右键单击 pom.xml 并选择 Maven->Reimport 这将自动为您执行类路径。
然后从树中转到主类并右键单击并选择 Run。 这应该在您的运行配置中创建一个临时配置。
其余的你可以在这里找到:
https://www.jetbrains.com/help/idea/running-applications.html
如果要作为 maven 项目运行,请使用以下命令:
https://www.jetbrains.com/help/idea/work-with-maven-goals.html
如果你想从终端作为 java jar 运行,当你构建你的 spring-boot-jar 时,按 CTRL+TAB+T(激活终端)并在终端中输入: java -jar target/yourjar.jar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.