简体   繁体   English

SpringBoot App不与java -jar一起运行

[英]SpringBoot App doesn't runs with java -jar

I have a SpringBoot app with the following POM.xml 我有一个带有以下POM.xml的SpringBoot应用程序

<?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>***</groupId>
<artifactId>iaasservicesportal</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>iaas-services-portal</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.5.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.7</java.version>
    <start-class>***.iaasservicesportal.IaasservicesportalApplication</start-class>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</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-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.2.0.4.0</version>
        <scope>system</scope>
        <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/ojdbc14-10.2.0.4.0.jar</systemPath>
    </dependency>

    <dependency>
        <groupId>com.jolbox</groupId>
        <artifactId>bonecp</artifactId>
        <version>0.8.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
    </dependency>

    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.7</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.38</version>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.2.0.4.0</version>
        <scope>system</scope>
        <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/ojdbc14-10.2.0.4.0.jar</systemPath>
    </dependency>

    <dependency>
        <groupId>***</groupId>
        <artifactId>datatables</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/datatables.jar</systemPath>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

    <resources>
        <!-- include main.properties -->
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>application.properties</include>
            </includes>
        </resource>

        <!-- exclude everything else from filtering -->
        <resource>
            <directory>src/main/resources</directory>
            <filtering>false</filtering>
            <excludes>
                <exclude>application.properties</exclude>
            </excludes>
        </resource>
    </resources>

</build>

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

<distributionManagement>
    <repository>
        <id>releases</id>
        <name>Repositorio de releases</name>
        <url>https://nexus.***.corp/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>Repositorio de snapshots</name>
        <url>https://nexus.***.corp/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
</distributionManagement>

This is the Main Class: 这是主类:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@SpringBootApplication
@EnableJpaRepositories(repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean.class)
public class IaasservicesportalApplication extends SpringBootServletInitializer{

    public static void main(String[] args) {
        SpringApplication.run(IaasservicesportalApplication.class, args);
    }

}

The problem is that I can export the project as a WAR file to deploy into a Tomcat Server and It works fine. 问题是我可以将项目导出为WAR文件以部署到Tomcat服务器中,并且工作正常。 But I need to create a JAR file and execute that with the java -jar command. 但是我需要创建一个JAR文件并使用java -jar命令执行它。 When I execute the JAR file with java -jar command I get the following errors: 当我使用java -jar命令执行JAR文件时,我收到以下错误:

https://gist.github.com/jopse/5fb6833341f3398e00476df7ed1f5c25 https://gist.github.com/jopse/5fb6833341f3398e00476df7ed1f5c25

I didn't found similar errors here. 我在这里没有发现类似的错误。 I found problems like jar command or jar exporting but not these errors 我发现jar命令或jar导出等问题,但没有发现这些错误

EDIT: Errors in gist.github.com instead of as code 编辑:gist.github.com中的错误而不是代码

EDIT: Added a dependency accidentally deleted 编辑:添加了一个意外删除的依赖项

Finnally, I have added theese dependencies to a Nexus server. 最后,我已将theese依赖项添加到Nexus服务器。 I have added that Nexus server to the POM file Resulting this code: 我已将Nexus服务器添加到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>***</groupId>
<artifactId>iaasservicesportal</artifactId>
<version>0.1-SNAPSHOT</version>

<name>iaas-services-portal</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.5.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.7</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</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-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.2.0.4.0</version>
    </dependency>

    <dependency>
        <groupId>***</groupId>
        <artifactId>datatables</artifactId>
        <version>1.0</version>
    </dependency>

    <dependency>
        <groupId>com.jolbox</groupId>
        <artifactId>bonecp</artifactId>
        <version>0.8.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
    </dependency>

    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.7</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.38</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>

    <resources>
        <!-- include main.properties -->
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>application.properties</include>
            </includes>
        </resource>

        <!-- exclude everything else from filtering -->
        <resource>
            <directory>src/main/resources</directory>
            <filtering>false</filtering>
            <excludes>
                <exclude>application.properties</exclude>
            </excludes>
        </resource>
    </resources>

</build>

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>

    <repository>
        <id>thirdparty</id>
        <name>Repositorio de terceras partes</name>
        <url>https://nexus.ci.***/nexus/content/repositories/thirdparty</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

<distributionManagement>
    <repository>
        <id>releases</id>
        <name>Repositorio de releases</name>
        <url>https://nexus.ci.***/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>Repositorio de snapshots</name>
        <url>https://nexus.ci.***/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
</distributionManagement>

<packaging>jar</packaging>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java-.jar文件用完了堆,但是没有在eclipse中执行 - Java - .jar file runs out of heap but executing in eclipse doesn't jar在Windows上运行但在Ubuntu上不运行 - jar runs on Windows but doesn't on Ubuntu Heroku上的Java Web应用程序运行但无法回答 - Java web app on Heroku runs but doesn't answer 使用Java JLayer的背景音乐在Eclipse和可运行的jar中播放,但在客户端下载并运行该客户端时不播放 - Background music using java JLayer plays in eclipse and runnable jar but doesn't play when a client downloads and runs it SpringBoot 不扫描微服务应用程序中的组件 - SpringBoot doesn't scan for components in microservices app 应用程序错误 Azure App Service trying to run Java/Springboot jar - Application error on Azure App Service trying to run Java/Springboot jar Springboot jar 运行,但不在 Docker 容器内 - Springboot jar runs, but not inside Docker container 项目在Eclipse中正常运行,但导出到可运行的jar时无法正常运行 - Project runs normal in Eclipse but doesn't when exported to a runnable jar Java程序运行正常但不编译 - Java program runs fine but doesn't compile Java程序“运行”但未编译 - Java Program **runs** but doesn't compile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM