首页新闻找找看学习计划

【急需大佬求助】springboot使用idea可以运行访问,但是打成jar包就包类未找到错误!求助

0
悬赏园豆:100 [待解决问题]

我在maven中指定了启动类,但是打成jar包执行的时候会报错$ java -jar springboottest-1.0-SNAPSHOT.jar
Exception in thread "main" java.lang.ClassNotFoundException: com.mop.ReadApplication
求大佬解答一下,非常感谢了,找了好多网页和资料就是解决不了

<modelVersion>4.0.0</modelVersion>

<groupId>com.mop.javaweb</groupId>
<artifactId>springboottest</artifactId>
<version>1.0-SNAPSHOT</version>

<!-- 依赖starter-parent-->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
</parent>

<dependencies>
    <!-- 这是一个web项目-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>log4j-over-slf4j</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- 从parent项目中出去logging这个包,因为我们使用的是log4j -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- 引入log4j支持 -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j</artifactId>
        <version>1.3.8.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>com.jayway.jsonpath</groupId>
        <artifactId>json-path</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- groovy支持-->
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>2.4.7</version>
    </dependency>
    <!-- 使用Mybatis-->
    <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>1.1.1</version>
    </dependency>
    <!-- jdbc驱动-->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>6.0.5</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <!-- 支持生成xml -->
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-xml</artifactId>
    </dependency>
</dependencies>

<properties>
    <java.version>1.8</java.version>
</properties>


<build>
    <plugins>

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <mainClass>com.mop.ReadApplication</mainClass>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
        </plugin>

    </plugins>
</build>

<repositories>
    <repository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </pluginRepository>
</pluginRepositories>

</project>

Tank_Dada的主页 Tank_Dada | 初学一级 | 园豆:54
提问于:2020-05-31 19:55
< >
分享
所有回答(2)
0

mark,没遇到这种情况

Tom.汤 | 园豆:1953 (小虾三级) | 2020-06-01 08:25
0
<build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <configuration>

                        <archive>
                            <manifest>
                                <mainClass>com.mop.ReadApplication</mainClass> 
                                <addClasspath>true</addClasspath>
                                <classpathPrefix>lib/</classpathPrefix>
                            </manifest>

                        </archive>
                        <classesDirectory>
                        </classesDirectory>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
悟行 | 园豆:12238 (专家六级) | 2020-06-01 08:41

不行啊大佬

支持(0) 反对(0) Tank_Dada | 园豆:54 (初学一级) | 2020-06-01 22:31

@Tank_Dada: 截图看看你加的

支持(0) 反对(0) 悟行 | 园豆:12238 (专家六级) | 2020-06-03 16:03
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册