【问题标题】:Migrating from tomcat 8 to jetty server从 tomcat 8 迁移到码头服务器
【发布时间】:2019-07-22 12:31:31
【问题描述】:

我在 tomcat 8 服务器上运行基于 java 的应用程序。最近我的 tomcat 出现了一些问题,所以我决定用码头服务器来改变它。我的问题与@Autowire 注释有关。这是我的更改和我的控制台。

我已经删除了tomcat的依赖和插件,并添加了一些我在网上找到的jetty。

    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-annotations</artifactId>
        <version>7.6.8.v20121106</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>apache-jsp</artifactId>
        <version>9.2.7.v20150116</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>apache-jstl</artifactId>
        <version>9.2.7.v20150116</version>
    </dependency>

    <plugin>
        <groupId>org.eclipse.jetty</groupId>
         <artifactId>jetty-maven-plugin</artifactId>
         <version>9.2.8.v20150217</version>
    </plugin>

这是我的控制台错误:

引起:org.springframework.beans.factory.BeanCreationException: 无法自动装配字段:私有 com.snt.hr.service.attendances.CheckInService com.snt.hr.tasks.AttendanceSyncTask.checkInService;

【问题讨论】:

    标签: java spring hibernate tomcat jetty


    【解决方案1】:

    现在您的问题没有包含足够的信息来给出正确的答案。

    但你的问题确实暗示了一些问题。

    对于所有依赖项和插件,您必须在各处使用相同版本的 Jetty。

    • Jetty 7 即将停产(生命周期结束)
    • Jetty 9.2 是 EOL(生命终结)

    使用最新、稳定和受支持的东西。

    https://www.eclipse.org/jetty/documentation/current/what-jetty-version.html

    如果您使用当前和最新的第 3 方库,那么至少使用 Jetty 9.4.9 或更新版本很重要(因为各种第 3 方库已开始采用 JSR-238 Multi-Release JAR Archive - https://openjdk.java.net/jeps/238 ,而 Jetty 对此类 JAR 档案的支持仅存在于 Jetty 9.4.x 中)

    请注意,一旦您升级 Jetty,您的 spring 依赖项(您的问题中没有列出)可能也需要升级,因为旧版本的 Spring 不能与新版本的 Jetty 一起使用,由于各种技术原因,一些 Jetty 正在做,一些 Java 正在做,一些 Spring 的错误假设。

    您选择的 Jetty 依赖项列表似乎很短。这是一个有效的列表,将帮助您入门,因为大多数更重要的依赖项将从 jetty-annotations 中提取,但这种基本设置是不寻常的。

    我看到你正在引入 JSP。 JSP 是一朵特别精致的技术之花,需要相当多的设置才能正常运行。

    见:https://github.com/jetty-project/embedded-jetty-jsp

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-26
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 2014-04-30
      • 2015-04-02
      相关资源
      最近更新 更多