我试图将我的webapp打包到胖罐中,以便用public class Operators {
public static void operate(double price, double low, String company){
double percent = (price/low-1)*100;
double rpercent = Math.round(percent * 100.0) / 100.0;
StringBuilder sb = new StringBuilder(32);
if(rpercent <= 10) {
sb.append(company + " is trading at:");
sb.append("the current price is: " + price);
sb.append("the 52 week low is: " + low);
sb.append("percent of 52 week low is: " + rpercent);
}
}
}
执行。当我执行java -jar my-app.jar
但当我尝试使用以下命令运行打包的jar时,一切正常。
mvn spring-boot:run
显示Spring Boot徽标,但是在3或4秒后,它会停止,无需启动任何服务器。
这是我的$ mvn clean package
$ java -jar target/my-app.jar
:
pom.xml
EDITED
启用日志后,我看到此错误:
org.springframework.context.ApplicationContextException:无法执行 启动嵌入式容器;嵌套异常是 org.springframework.boot.context.embedded.EmbeddedServlet ContainerException:无法启动嵌入式Tomcat
使用名称&#39; jerseyConfig&#39;创建bean时出错在URL ...中定义。
我有一个班级<?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.digitalmenu</groupId>
<artifactId>services</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jooq</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</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>
...
我已经尝试了this但仍然没有工作......
答案 0 :(得分:1)
最后,我找到了答案!感谢OP在this问题的答案中发表评论。
我正在注册Jersey资源:
packages("com.myapp.resources");
单独注册每个人的一切都有效:
register(Res1.class);
register(Res2.class);
...