spingboot2.0外部引入xml配置文件时找不到文件等报错
之前的项目可以启动,后面不知道为什么都不行了,报错如下:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/G:/sharp/repo/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/G:/sharp/repo/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] . ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.0.RELEASE) 2018-12-10 11:24:14.461 INFO 1400 --- [ main] c.sharp.forward.SharpServiceApplication : Starting SharpServiceApplication on hh-PC with PID 1400 (G:\worksheet\sharp-service\target\classes started by Administrator in G:\worksheet\sharp-service)
2018-12-10 11:24:14.465 INFO 1400 --- [ main] c.sharp.forward.SharpServiceApplication : No active profile set, falling back to default profiles: default
2018-12-10 11:24:14.902 WARN 1400 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [config/application-user-service-dubbo.xml]; nested exception is java.io.FileNotFoundException: class path resource [config/application-user-service-dubbo.xml] cannot be opened because it does not exist
2018-12-10 11:24:14.910 INFO 1400 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-12-10 11:24:14.915 ERROR 1400 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [config/application-user-service-dubbo.xml]; nested exception is java.io.FileNotFoundException: class path resource [config/application-user-service-dubbo.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:224) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:195) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromImportedResources$0(ConfigurationClassBeanDefinitionReader.java:358) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at java.util.LinkedHashMap.forEach(Unknown Source) ~[na:1.8.0_171]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromImportedResources(ConfigurationClassBeanDefinitionReader.java:325) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:327) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:691) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at com.sharp.forward.SharpServiceApplication.main(SharpServiceApplication.java:13) [classes/:na]
Caused by: java.io.FileNotFoundException: class path resource [config/application-user-service-dubbo.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE]
... 22 common frames omitted
说是找不到我的dubbo.xml的配置文件,但是我认真查看均没有配错:代码片段如下:
/**
* xml配置导入代码
*/
package com.sharp.forward.config; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource; /**
* @author 醉逍遥
*
*/
@Configuration
@ImportResource("classpath:config/application-user-service-dubbo.xml")
public class DubboConfig { } //启动部分如下:其中包含另一种导入方式,是一样的,这里注释掉了
package com.sharp.forward; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication
//@ImportResource("classpath:config/application-user-service-dubbo.xml")
@MapperScan(basePackages= {"com.sharp.forward.mapper"})
public class SharpServiceApplication { public static void main(String[] args) {
SpringApplication.run(SharpServiceApplication.class, args);
} }
代码结构
各种找问题都集中在配置上,但是配置正确都没有解决,最后,参考博客https://www.jianshu.com/p/836d455663da解决了,问题出在该博客四。资源打包没有打包进来,
修改之前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>
<parent>
<groupId>com.sharp</groupId>
<artifactId>sharp-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>sharp-service</artifactId>
<packaging>jar</packaging> <name>sharp-sevice</name>
<description>Demo project for Spring Boot</description>
<dependencies>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.sharp</groupId>
<artifactId>sharp-entity</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.sharp</groupId>
<artifactId>sharp-common</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.sharp</groupId>
<artifactId>sharp-mapper</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.sharp</groupId>
<artifactId>sharp-service-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.gitee.reger/spring-boot-starter-dubbo -->
<!-- <dependency>
<groupId>com.gitee.reger</groupId>
<artifactId>spring-boot-starter-dubbo</artifactId>
<version>1.1.1</version>
</dependency>
-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <profiles>
<profile>
<id>local</id>
<properties>
<profile.active>local</profile.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>dev</id>
<properties>
<profile.active>dev</profile.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
<build> <resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>application-local.properties</exclude>
<exclude>application-dev.properties</exclude>
</excludes>
<includes>
<include>application-${profile.active}.properties</include>
</includes>
</resource>
</resources>
<plugins>
<!-- <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.sharp.forward.SharpServiceApplication.java</mainClass>
</configuration>
</plugin> -->
<!-- 打包插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<!--指定main入口-->
<mainClass>com.sharp.forward.SharpServiceApplication.java</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>../lib/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>../conf/</Class-Path>
</manifestEntries>
</archive>
<excludes>
<exclude>config/**</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/resources/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions><!--执行器 mvn assembly:assembly-->
<execution>
<id>make-assembly</id><!--名字任意 -->
<phase>package</phase><!-- 绑定到package生命周期阶段上 -->
<goals>
<goal>single</goal><!-- 只运行一次 -->
</goals>
</execution>
</executions>
</plugin> </plugins>
</build> </project>
修改之后代码主要更改了build中resources内容
<?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>
<parent>
<groupId>com.sharp</groupId>
<artifactId>sharp-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>sharp-service</artifactId>
<packaging>jar</packaging> <name>sharp-sevice</name>
<description>Demo project for Spring Boot</description>
<dependencies>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.sharp</groupId>
<artifactId>sharp-entity</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.sharp</groupId>
<artifactId>sharp-common</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.sharp</groupId>
<artifactId>sharp-mapper</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.sharp</groupId>
<artifactId>sharp-service-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.gitee.reger/spring-boot-starter-dubbo -->
<!-- <dependency>
<groupId>com.gitee.reger</groupId>
<artifactId>spring-boot-starter-dubbo</artifactId>
<version>1.1.1</version>
</dependency>
-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <profiles>
<profile>
<id>local</id>
<properties>
<profile.active>local</profile.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>dev</id>
<properties>
<profile.active>dev</profile.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
<build>
<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources> <!-- <resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>application-local.properties</exclude>
<exclude>application-dev.properties</exclude>
</excludes>
<includes>
<include>application-${profile.active}.properties</include>
</includes>
</resource>
</resources> -->
<plugins>
<!-- <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.sharp.forward.SharpServiceApplication.java</mainClass>
</configuration>
</plugin> -->
<!-- 打包插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<!--指定main入口-->
<mainClass>com.sharp.forward.SharpServiceApplication.java</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>../lib/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>../conf/</Class-Path>
</manifestEntries>
</archive>
<excludes>
<exclude>config/**</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/resources/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions><!--执行器 mvn assembly:assembly-->
<execution>
<id>make-assembly</id><!--名字任意 -->
<phase>package</phase><!-- 绑定到package生命周期阶段上 -->
<goals>
<goal>single</goal><!-- 只运行一次 -->
</goals>
</execution>
</executions>
</plugin> </plugins>
</build> </project>
然后问题解决,
根据自己打包需要动态,对两个pom.xml整合后如下“
<?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>
<parent>
<groupId>com.sharp</groupId>
<artifactId>sharp-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>sharp-service</artifactId>
<packaging>jar</packaging> <name>sharp-sevice</name>
<description>Demo project for Spring Boot</description>
<dependencies>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.sharp</groupId>
<artifactId>sharp-entity</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.sharp</groupId>
<artifactId>sharp-common</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.sharp</groupId>
<artifactId>sharp-mapper</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.sharp</groupId>
<artifactId>sharp-service-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.gitee.reger/spring-boot-starter-dubbo -->
<!-- <dependency>
<groupId>com.gitee.reger</groupId>
<artifactId>spring-boot-starter-dubbo</artifactId>
<version>1.1.1</version>
</dependency>
-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <profiles>
<profile>
<id>local</id>
<properties>
<profile.active>local</profile.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>dev</id>
<properties>
<profile.active>dev</profile.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
<build>
<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>application-local.properties</exclude>
<exclude>application-dev.properties</exclude>
</excludes>
<includes>
<include>**/*.yml</include>
<include>application.properties</include>
<include>application-${profile.active}.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<!-- <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.sharp.forward.SharpServiceApplication.java</mainClass>
</configuration>
</plugin> -->
<!-- 打包插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<!--指定main入口-->
<mainClass>com.sharp.forward.SharpServiceApplication.java</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>../lib/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>../conf/</Class-Path>
</manifestEntries>
</archive>
<excludes>
<exclude>config/**</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/resources/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions><!--执行器 mvn assembly:assembly-->
<execution>
<id>make-assembly</id><!--名字任意 -->
<phase>package</phase><!-- 绑定到package生命周期阶段上 -->
<goals>
<goal>single</goal><!-- 只运行一次 -->
</goals>
</execution>
</executions>
</plugin> </plugins>
</build> </project>
重新构建编译,仍正常启动,ok!
spingboot2.0外部引入xml配置文件时找不到文件等报错的更多相关文章
- IAR 编译时找不到头文件的解决方法
Fatal Error[Pe1696]: cannot open source file "x.h" 那是因为头文件路径没有找对 到报错的.c源文件 选中右键 选择options ...
- SPRING IN ACTION 第4版笔记-第二章WIRING BEANS-008-在Java配置文件中引入xml配置文件@Import、@ImportResource
1. package soundsystem; import org.springframework.beans.factory.annotation.Autowired; public class ...
- [error] eclipse编写spring等xml配置文件时只有部分提示,tx无提示
eclipse编写spring等xml配置文件时只有<bean>.<context>等有提示,其他标签都没有提示 这时就需要做以下两步操作(下面以事务管理标签为例) 1,添加命 ...
- eclipse java项目中明明引入了jar包 为什么项目启动的时候不能找到jar包 项目中已经 引入了 com.branchitech.app 包 ,但时tomcat启动的时候还是报错? java.lang.ClassNotFoundException: com.branchitech.app.startup.AppStartupContextListener java.lang.ClassN
eclipse java项目中明明引入了jar包 为什么项目启动的时候不能找到jar包 项目中已经 引入了 com.branchitech.app 包 ,但时tomcat启动的时候还是报错?java. ...
- struts2.0中struts.xml配置文件详解
先来展示一个配置文件 <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration ...
- linux 使用ptrace函数时找不到头文件 .h 或者找不到某个宏的解决方法
例如: #include <stdio.h> #include <sys/ptrace.h> #include <sys/types.h> #include < ...
- mysql创建表时,设置timestamp DEFAULT NULL报错1067 - Invalid default value for 'updated_at'
问题背景: 线上的linux服务器上的mysql服务器中导出数据库的结构.想要在本地创建一个测试版本 导出后再本地mysql上运行却报错 1067 - Invalid default value ...
- php7.0 出现 curl_setopt(): Disabling safe uploads is no longer supported in 报错!
项目换成php7.0,进行了测试,使用curl时,出现: curl_setopt(): Disabling safe uploads is no longer supported in xxx.定位到 ...
- 聊聊、dubbo 找不到 dubbo.xsd 报错
平常在用 Dubbo 的时候,创建 xml 会提示 http://code.alibabatech.com/schema/dubbo/dubbo.xsd 找不到. 大家可以去 https://gith ...
随机推荐
- linux文件或目录属性
wc(word count)命令的功能:统计指定文件的字节数.字数.行数.,并将统计结果显示输出 命令参数: -c 只显示字节数 -l 只显示行数 -w 只显示字数 od命令:查看二进制文件信息 ...
- ng-class 动态设置css
可使用ng-class 动态设置class ,设置disable后,发现ng-click 居然还可以使用,不知什么原因. <li ng-class="{disabled:!first} ...
- extractvalue报错注入
查看源码 $uagent = $_SERVER['HTTP_USER_AGENT']; ………… $uname = check_input($_POST['uname']); $passwd = ch ...
- Layui我提交表单时,table.reload(),表格会请求2次,是为什么?
重载两次是因为搜索按钮用的是button 改成<a class="layui-btn" data-type="reload">搜索</a> ...
- mongodb插入性能
转自 https://blog.csdn.net/asdfsadfasdfsa/article/details/60872180 MongoDB与MySQL的插入.查询性能测试 7.1 平均 ...
- PAT A1151 LCA in Binary Tree
利用树的前序和中序递归判定最小公共祖先~ 直接根据两个序列递归处理~ #include<bits/stdc++.h> using namespace std; ; int N,M; int ...
- 华为事件对A股的影响思考
美国对华为实施禁商令: 利好:自主可控-替代品 软件:国产操作系统(中国软件,浪潮软件,湘邮科技...) 芯片:国产芯片(士微兰,国民技术...) 利好:华为优势产品 5G: 利好:反制资源 稀土永磁 ...
- LSTM算法公式
参考:<基于强化学习的开放领域聊天机器人对话生成算法>
- Servlet 设置字符编码filter
filter package common; import javax.servlet.*; import java.io.IOException; public class EncodingFilt ...
- 第2节 Scala中面向对象编程:7、继承的概念以及override和super关键字;8、isInstanceOf 和 asInstanceOf关键字
6.3. Scala面向对象编程之继承 6.3.1. Scala中继承(extends)的概念 Scala 中,让子类继承父类,与 Java 一样,也是使用 extends 关键字: 继承 ...