Java Spark 框架,部署失败

标签 java maven intellij-idea spark-framework

这看起来应该是一项微不足道的任务。但我不太清楚我应该做什么。我是 Maven/Spark 的新手。在四处搜索之后,仔细查看文档等等。我不知道如何启动我的 spark 应用程序?

我按照本指南在 Intellij 中进行了设置。 https://sparktutorials.github.io/2015/04/02/setting-up-a-spark-project-with-maven.html

我可以运行除部署之外的所有 Maven 任务。

enter image description here

部署失败并出现此错误。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project framework: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

我不确定这是否重要?部署任务是否旨在启动服务器?我不确定。

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>

  <groupId>com.krishollenbeck.framework</groupId>
  <artifactId>framework</artifactId>
  <version>1.0</version>
  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
  <dependencies>
    <dependency>
      <groupId>com.sparkjava</groupId>
      <artifactId>spark-core</artifactId>
      <version>2.5</version>
    </dependency>
  </dependencies>
</project>

这是 DOCS 所说的。

What about starting the server? The server is automatically started when you do something that requires the server to be started (i.e. declaring a route or setting the port). You can also manually start the server by calling init().

http://sparkjava.com/documentation.html#stopping-the-server

好吗?这意味着什么?通常有一些命令或其他东西来启动服务器。

问题:长话短说

如何启动 spark 服务器?

另一种题外话:

spark还在维护吗?这是一个不好用的框架吗?我正在寻找一个轻量级的 Java 服务器。大多数应用程序逻辑将在客户端处理。只需要在服务器端处理一些基本的登录/CRUD 内容。并构建一些 Restful API。

项目结构:(仅供引用)

enter image description here

最佳答案

从 Intellij 运行您的主类。或者,如果您想使用 maven 运行它,请执行以下操作:

mvn exec:java -Dexec.mainClass=my.IakaMain

并确保将 my.IakaMain 更改为 yourpackage.YourClassName

或通过 Intellij 调试配置运行:(像这样)

enter image description here

运行查看:(注意端口号不是通常的80或8080)

http://localhost:4567/hello

注意:如果您收到此警告(烦人)。

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

将此添加到您的 pom.xml

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.21</version>
</dependency>

关于Java Spark 框架,部署失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42490883/

相关文章:

java - Google Java 样式 : Import names v. s。导入语句?

Maven 跳过测试

eclipse - 为什么 Eclipse Birt 3.7 没有 Maven 存储库 => Birt 4.2 有一个

java - 无法解析 'com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory'

intellij-idea - 如何防止 Intellij IDEA 自动关注调试器事件?

ant - 让 IntelliJ 显示 Ant 构建的所有错误

java - 在java中将 double 转换为二进制数

java - 使用 gson 从对象列表中获取 JSON 字符串

java - 在 @CollectionElement hibernate 中使用 createCriteria

android - 与 Android Gradle 插件并行处理应用程序和外部库