首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Collosus World示例

Collosus World示例
EN

Stack Overflow用户
提问于 2016-09-19 20:25:58
回答 1查看 280关注 0票数 1

我想用Colossus做一个REST服务器。但是,我很难运行这里显示的hello world示例,http://tumblr.github.io/colossus/docs/quickstart/

我想使用maven,所以我创建了一个maven项目。这是我的pom.xml:

代码语言:javascript
复制
<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>deneme</groupId>
  <artifactId>deneme</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
        <directory>src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
            <groupId>com.google.code.sbt-compiler-maven-plugin</groupId>
            <artifactId>sbt-compiler-maven-plugin</artifactId>
            <version>1.0.0-beta9</version>
            <executions>
                <execution>
                    <id>default-sbt-compile</id>
                    <goals>
                        <goal>compile</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
    <groupId>com.tumblr</groupId>
    <artifactId>colossus-metrics_2.10</artifactId>
    <version>0.8.1</version>
    </dependency>
</dependency>
  </dependencies>
</project>

如你所见,我包含了巨像的依赖项。然而,在下面的代码中,我在构建时得到了一个错误,说没有找到: object core。除了colossus之外,其余的import语句也有类似的错误。

代码语言:javascript
复制
import colossus._
import core._
import service._
import protocols.http._
import UrlParsing._
import HttpMethod._

class HelloService(context: ServerContext) extends HttpService(context) {
  def handle = {
    case request @ Get on Root / "hello" => {
      Callback.successful(request.ok("Hello World!"))
    }
  }
}

class HelloInitializer(worker: WorkerRef) extends Initializer(worker) {

  def onConnect = context => new HelloService(context)

}


object Main extends App {

  implicit val io = IOSystem()

  Server.start("hello-world", 9000){ worker => new HelloInitializer(worker) }

}

我得到的错误如下:

代码语言:javascript
复制
Compiling 1 Scala source to /bighome/saygin/workspace/deneme/target/classes...
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:2: not found: object core
[ERROR] import core._
[ERROR]        ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:3: not found: object service
[ERROR] import service._
[ERROR]        ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:4: not found: object protocols
[ERROR] import protocols.http._
[ERROR]        ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:5: not found: object UrlParsing
[ERROR] import UrlParsing._
[ERROR]        ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:6: not found: object HttpMethod
[ERROR] import HttpMethod._
[ERROR]        ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:8: not found: type HttpService
[ERROR] class HelloService(context: ServerContext) extends HttpService(context) {
[ERROR]                                                    ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:8: not found: type ServerContext
[ERROR] class HelloService(context: ServerContext) extends HttpService(context) {
[ERROR]                             ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:9: missing parameter type for expanded function
The argument types of an anonymous function must be fully known. (SLS 8.5)
Expected type was: ?
[ERROR]   def handle = {
[ERROR]                ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:10: not found: value on
[ERROR]     case request @ Get on Root / "hello" => {
[ERROR]                        ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:10: not found: value Get
[ERROR]     case request @ Get on Root / "hello" => {
[ERROR]                    ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:10: not found: value /
[ERROR]     case request @ Get on Root / "hello" => {
[ERROR]                                ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:10: not found: value Root
[ERROR]     case request @ Get on Root / "hello" => {
[ERROR]                           ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:11: not found: value Callback
[ERROR]       Callback.successful(request.ok("Hello World!"))
[ERROR]       ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:16: not found: type Initializer
[ERROR] class HelloInitializer(worker: WorkerRef) extends Initializer(worker) {
[ERROR]                                                   ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:16: not found: type WorkerRef
[ERROR] class HelloInitializer(worker: WorkerRef) extends Initializer(worker) {
[ERROR]                                ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:25: not found: value IOSystem
[ERROR]   implicit val io = IOSystem()
[ERROR]                     ^
[ERROR] /bighome/saygin/workspace/deneme/src/myapp.scala:27: not found: value Server
[ERROR]   Server.start("hello-world", 9000){ worker => new HelloInitializer(worker) }
[ERROR]   ^
[ERROR] 17 errors found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45:26 min
[INFO] Finished at: 2016-09-19T13:50:18+03:00
[INFO] Final Memory: 24M/514M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.code.sbt-compiler-maven-plugin:sbt-compiler-maven-plugin:1.0.0-beta9:compile (default-sbt-compile) on project deneme: Scala compilation failed: CompileFailed -> [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.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

我该怎么办?

EN

回答 1

Stack Overflow用户

发布于 2016-09-19 22:16:16

看起来你只是添加了colossus-metrics_2.10作为一个依赖项,然而这实际上并不依赖于巨人本身,所以你实际上并不是在拉入巨人。

我没有尝试复制我自己,但我认为如果您为colossus_2.10添加另一个依赖项,它应该会解决这个问题。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39573140

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档