- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个 spring boot 应用程序,我使用它来运行:
mvn spring-boot:run
这工作得很好。我想使用 java -jar
选项运行这个应用程序,当我运行它时:
java $JAVA_OPTS -jar target/backend-1.0-SNAPSHOT.jar --server.port=8080 $JAR_OPTS
我收到这个错误:
org.glassfish.jersey.server.internal.scanning.ResourceFinderException: java.io.FileNotFoundException: /Users/cat/IdeaProjects/backend/target/backend-1.0-SNAPSHOT.jar!/BOOT-INF/classes (No such file or directory
我不明白为什么?我在谷歌上搜索了很多,但没有任何运气。我们有 mvn spring-boot:run
的替代方法吗?
我想这样做是因为我在 heroku 上部署,当我输入 Procfile
web: mvn spring-boot:run
时,我得到了 mvn 这样的错误不存在
编辑这是我要运行的代码:
https://github.com/jasenkoh/spring-boot-jersey-hibernate
整个堆栈跟踪:
type Exception report
message Servlet.init() for servlet servletContainer threw exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet servletContainer threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
root cause
A MultiException has 1 exceptions. They are:
1. org.glassfish.jersey.server.internal.scanning.ResourceFinderException: java.io.FileNotFoundException: /Users/asfandyar/IdeaProjects/spring-boot-jersey-hibernate/target/spring-boot-jersey-hibernate-1.0-SNAPSHOT.jar!/BOOT-INF/classes (No such file or directory)
org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:1011)
org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:961)
org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1053)
org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1045)
org.glassfish.jersey.server.ApplicationHandler.createApplication(ApplicationHandler.java:385)
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:342)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
root cause
org.glassfish.jersey.server.internal.scanning.ResourceFinderException: java.io.FileNotFoundException: /Users/asfandyar/IdeaProjects/spring-boot-jersey-hibernate/target/spring-boot-jersey-hibernate-1.0-SNAPSHOT.jar!/BOOT-INF/classes (No such file or directory)
org.glassfish.jersey.server.internal.scanning.JarZipSchemeResourceFinderFactory.create(JarZipSchemeResourceFinderFactory.java:89)
org.glassfish.jersey.server.internal.scanning.JarZipSchemeResourceFinderFactory.create(JarZipSchemeResourceFinderFactory.java:65)
org.glassfish.jersey.server.internal.scanning.PackageNamesScanner.addResourceFinder(PackageNamesScanner.java:282)
org.glassfish.jersey.server.internal.scanning.PackageNamesScanner.init(PackageNamesScanner.java:198)
org.glassfish.jersey.server.internal.scanning.PackageNamesScanner.<init>(PackageNamesScanner.java:154)
org.glassfish.jersey.server.internal.scanning.PackageNamesScanner.<init>(PackageNamesScanner.java:110)
org.glassfish.jersey.server.ResourceConfig.packages(ResourceConfig.java:680)
com.jersey.config.JerseyInitialization.<init>(JerseyInitialization.java:15)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1350)
org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:1009)
org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:961)
org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1053)
org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1045)
org.glassfish.jersey.server.ApplicationHandler.createApplication(ApplicationHandler.java:385)
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:342)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
root cause
java.io.FileNotFoundException: /Users/asfandyar/IdeaProjects/spring-boot-jersey-hibernate/target/spring-boot-jersey-hibernate-1.0-SNAPSHOT.jar!/BOOT-INF/classes (No such file or directory)
java.io.FileInputStream.open0(Native Method)
java.io.FileInputStream.open(FileInputStream.java:195)
java.io.FileInputStream.<init>(FileInputStream.java:138)
java.io.FileInputStream.<init>(FileInputStream.java:93)
sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
java.net.URL.openStream(URL.java:1045)
org.glassfish.jersey.server.internal.scanning.JarZipSchemeResourceFinderFactory.getInputStream(JarZipSchemeResourceFinderFactory.java:177)
org.glassfish.jersey.server.internal.scanning.JarZipSchemeResourceFinderFactory.create(JarZipSchemeResourceFinderFactory.java:87)
org.glassfish.jersey.server.internal.scanning.JarZipSchemeResourceFinderFactory.create(JarZipSchemeResourceFinderFactory.java:65)
org.glassfish.jersey.server.internal.scanning.PackageNamesScanner.addResourceFinder(PackageNamesScanner.java:282)
org.glassfish.jersey.server.internal.scanning.PackageNamesScanner.init(PackageNamesScanner.java:198)
org.glassfish.jersey.server.internal.scanning.PackageNamesScanner.<init>(PackageNamesScanner.java:154)
org.glassfish.jersey.server.internal.scanning.PackageNamesScanner.<init>(PackageNamesScanner.java:110)
org.glassfish.jersey.server.ResourceConfig.packages(ResourceConfig.java:680)
com.jersey.config.JerseyInitialization.<init>(JerseyInitialization.java:15)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1350)
org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:1009)
org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:961)
org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1053)
org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1045)
org.glassfish.jersey.server.ApplicationHandler.createApplication(ApplicationHandler.java:385)
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:342)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
我的 pom 文件在这里可用:
<?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.jersey</groupId>
<artifactId>spring-boot-jersey-hibernate</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
<properties>
<start-class>com.jersey.Application</start-class>
<postgresql-version>9.4.1209.jre7</postgresql-version>
<jersey-version>2.23.1</jersey-version>
<jackson-version>2.8.1</jackson-version>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- End Spring -->
<!-- Postgres -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql-version}</version>
</dependency>
<!-- End Postgres -->
<!-- Jersey -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-bean-validation</artifactId>
<version>${jersey-version}</version>
</dependency>
<!-- End Jersey -->
<!-- Jackson -->
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate4</artifactId>
<version>${jackson-version}</version>
</dependency>
<!-- End Jackson -->
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<url>http://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>http://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
最佳答案
您可以通过配置 spring boot maven 插件使您的 jar 可执行:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
用
打包你的jarmvn package
然后您可以通过键入 ./backend-1.0-SNAPSHOT.jar
来运行您的应用程序>
https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html
关于java - 替代 mvn spring-boot :run,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43967056/
我正在为我的项目使用 Maven。如果我的项目不使用某些本地资源,这不是问题。 以便我遵循本指南 https://stackoverflow.com/a/61576687/6720896 将我的本地
今天我尝试通过 Maven 使用 site 命令生成报告,在编译阶段遇到了问题。 错误: ParseException in /Users/rajesh/Documents/workspace/mob
这个问题已经有答案了: Mvn install or Mvn package (8 个回答) 已关闭 6 年前。 我是一名新开发人员,一生中从未使用过 eclipse 或 java,我正在尝试做一些事
我知道mvn:package可以用来生成JAR或WAR,mvn:assemble有什么区别吗? 最佳答案 他们是完全不同的。 “package”是一个简单的命令,用于简单/单个项目,您只需创建一个 j
我正在使用 Maven 运行单个测试。 以这两种方式运行它的区别是: mvn -Dtest=DatabaseTest test mvn -Dtest=DatabaseTest surefire:tes
我已经从 svn checkout 了一个项目。我正在尝试使用 Maven 构建项目。 使用 mvn 编译可以很好地构建。 当我尝试命令 mvn package 时,出现以下错误。 [INFO] --
当我使用 Maven 故障安全插件运行集成测试时遇到问题。我有两个类,一个是 TestUnitTest.java,另一个是 TestIntegrationIT.java。在pom.xml中,我配置如下
我有一个测试用例: import org.graph.*; import org.junit.*; public class TestCase_1 { @Test public voi
大家好,我有这两个问题 mvn clean 我收到此警告消息 Some problems were encountered while building the effective model for
Maven的mvn install和mvn verify命令有什么区别? 关键字clean如何修改这些命令? 最佳答案 mvn verify - 如前所述 - 执行 maven 在项目中找到的任何集成
我正在关注 Scala, Eclipse and Maven Integration tutorial . 这真的很有用。 但是有一件事情让我觉得很烦: 我总是需要从 Eclipse 运行两个命令作为
虽然我知道 mvn install -U 用于 update-snapshots 并且它更新了从构建日志中看到的远程存储库中的所有内容,但我无法了解它会强制更新哪一部分。因为据我了解,即使是 mvn
我已经阅读了@ codehaus exec-maven-plugin usage 的文档.我知道 exec:java 允许用户在他们声明的同一个 VM 中执行 java 程序。我是 Maven 的新手
我正在使用树脂服务器开发一个 Java 项目(其中 maven 是构建工具)。我找到了一些不错的 plugins对于 Tomcat,如果我发出 'mvn compile'然后编译文件转到/webapp
我有一个打包为 war 文件(包括几个 jar 文件)的 Web 应用程序。我注意到当我运行 mvn install 时——唯一被编译的项目是那些已经改变的——然后它替换了 war 文件中的这些 ja
这个问题在这里已经有了答案: IDEA JetBrains IntelliJ - Compile error on 'make' but fine when compiled using Maven
mvn clean install和mvn install有什么区别? 最佳答案 clean 在 Maven 中是它自己的构建生命周期阶段(可以被认为是一个 Action 或任务)。 mvn clea
我的团队使用内部团队 Maven 存储库,该存储库是使用 Apache 从开发服务器共享的。我们还在同一台机器上运行 Continuum CI 服务器。 Continuum 中的 Maven 构建以“
我正在尝试执行“mvn install”以从 Dockerfile 创建 war 文件。波纹管是Dockerfile FROM scratch FROM ubuntu:16.04 RUN mkdir
mvn 验证失败并抛出依赖错误。 Dependency convergence error for com.company.concepts:patients:2.4.14-SNAPSHOT path
我是一名优秀的程序员,十分优秀!