之前的项目可以启动,后面不知道为什么都不行了,报错如下:
1 SLF4J: Class path contains multiple SLF4J bindings. 2 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] 3 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] 4 SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 5 SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] 6 7 . ____ _ __ _ _ 8 /\\ / ___‘_ __ _ _(_)_ __ __ _ \ \ \ 9 ( ( )\___ | ‘_ | ‘_| | ‘_ \/ _` | \ \ \ 10 \\/ ___)| |_)| | | | | || (_| | ) ) ) ) 11 ‘ |____| .__|_| |_|_| |_\__, | / / / / 12 =========|_|==============|___/=/_/_/_/ 13 :: Spring Boot :: (v2.1.0.RELEASE) 14 15 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) 16 2018-12-10 11:24:14.465 INFO 1400 --- [ main] c.sharp.forward.SharpServiceApplication : No active profile set, falling back to default profiles: default 17 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 18 2018-12-10 11:24:14.910 INFO 1400 --- [ main] ConditionEvaluationReportLoggingListener : 19 20 Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug‘ enabled. 21 2018-12-10 11:24:14.915 ERROR 1400 --- [ main] o.s.boot.SpringApplication : Application run failed 22 23 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 24 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] 25 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] 26 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] 27 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:224) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] 28 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:195) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] 29 at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromImportedResources$0(ConfigurationClassBeanDefinitionReader.java:358) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] 30 at java.util.LinkedHashMap.forEach(Unknown Source) ~[na:1.8.0_171] 31 at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromImportedResources(ConfigurationClassBeanDefinitionReader.java:325) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] 32 at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] 33 at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] 34 at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:327) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] 35 at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] 36 at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] 37 at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] 38 at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:691) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] 39 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] 40 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] 41 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] 42 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] 43 at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] 44 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] 45 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] 46 at com.sharp.forward.SharpServiceApplication.main(SharpServiceApplication.java:13) [classes/:na] 47 Caused by: java.io.FileNotFoundException: class path resource [config/application-user-service-dubbo.xml] cannot be opened because it does not exist 48 at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] 49 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] 50 ... 22 common frames omitted
说是找不到我的dubbo.xml的配置文件,但是我认真查看均没有配错:代码片段如下:
1 /** 2 * xml配置导入代码 3 */ 4 package com.sharp.forward.config; 5 6 import org.springframework.context.annotation.Configuration; 7 import org.springframework.context.annotation.ImportResource; 8 9 /** 10 * @author 醉逍遥 11 * 12 */ 13 @Configuration 14 @ImportResource("classpath:config/application-user-service-dubbo.xml") 15 public class DubboConfig { 16 17 } 18 19 20 //启动部分如下:其中包含另一种导入方式,是一样的,这里注释掉了 21 package com.sharp.forward; 22 23 import org.mybatis.spring.annotation.MapperScan; 24 import org.springframework.boot.SpringApplication; 25 import org.springframework.boot.autoconfigure.SpringBootApplication; 26 import org.springframework.context.annotation.ImportResource; 27 @SpringBootApplication 28 //@ImportResource("classpath:config/application-user-service-dubbo.xml") 29 @MapperScan(basePackages= {"com.sharp.forward.mapper"}) 30 public class SharpServiceApplication { 31 32 public static void main(String[] args) { 33 SpringApplication.run(SharpServiceApplication.class, args); 34 } 35 36 }
代码结构
各种找问题都集中在配置上,但是配置正确都没有解决,最后,参考博客https://www.jianshu.com/p/836d455663da解决了,问题出在该博客四。资源打包没有打包进来,
修改之前pom
1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4 <modelVersion>4.0.0</modelVersion> 5 <parent> 6 <groupId>com.sharp</groupId> 7 <artifactId>sharp-pom</artifactId> 8 <version>0.0.1-SNAPSHOT</version> 9 </parent> 10 <artifactId>sharp-service</artifactId> 11 <packaging>jar</packaging> 12 13 <name>sharp-sevice</name> 14 <description>Demo project for Spring Boot</description> 15 <dependencies> 16 <!-- <dependency> 17 <groupId>org.springframework.boot</groupId> 18 <artifactId>spring-boot-starter-amqp</artifactId> 19 </dependency> 20 <dependency> 21 <groupId>org.springframework.boot</groupId> 22 <artifactId>spring-boot-starter-data-mongodb</artifactId> 23 </dependency> 24 <dependency> 25 <groupId>org.springframework.boot</groupId> 26 <artifactId>spring-boot-starter-data-redis</artifactId> 27 </dependency> --> 28 <dependency> 29 <groupId>org.springframework.boot</groupId> 30 <artifactId>spring-boot-starter-web</artifactId> 31 </dependency> 32 <dependency> 33 <groupId>com.alibaba</groupId> 34 <artifactId>druid</artifactId> 35 </dependency> 36 <dependency> 37 <groupId>org.springframework</groupId> 38 <artifactId>spring-jdbc</artifactId> 39 </dependency> 40 <dependency> 41 <groupId>com.sharp</groupId> 42 <artifactId>sharp-entity</artifactId> 43 <version>${project.parent.version}</version> 44 </dependency> 45 <dependency> 46 <groupId>com.sharp</groupId> 47 <artifactId>sharp-common</artifactId> 48 <version>${project.parent.version}</version> 49 </dependency> 50 <dependency> 51 <groupId>com.sharp</groupId> 52 <artifactId>sharp-mapper</artifactId> 53 <version>${project.parent.version}</version> 54 </dependency> 55 <dependency> 56 <groupId>com.sharp</groupId> 57 <artifactId>sharp-service-api</artifactId> 58 <version>${project.parent.version}</version> 59 </dependency> 60 <dependency> 61 <groupId>org.mybatis.spring.boot</groupId> 62 <artifactId>mybatis-spring-boot-starter</artifactId> 63 </dependency> 64 <dependency> 65 <groupId>mysql</groupId> 66 <artifactId>mysql-connector-java</artifactId> 67 </dependency> 68 <dependency> 69 <groupId>org.apache.zookeeper</groupId> 70 <artifactId>zookeeper</artifactId> 71 </dependency> 72 <dependency> 73 <groupId>com.101tec</groupId> 74 <artifactId>zkclient</artifactId> 75 <version>0.9</version> 76 </dependency> 77 <!-- https://mvnrepository.com/artifact/com.gitee.reger/spring-boot-starter-dubbo --> 78 <!-- <dependency> 79 <groupId>com.gitee.reger</groupId> 80 <artifactId>spring-boot-starter-dubbo</artifactId> 81 <version>1.1.1</version> 82 </dependency> 83 --> 84 <dependency> 85 <groupId>com.alibaba</groupId> 86 <artifactId>dubbo</artifactId> 87 <exclusions> 88 <exclusion> 89 <groupId>org.springframework</groupId> 90 <artifactId>spring</artifactId> 91 </exclusion> 92 </exclusions> 93 </dependency> 94 <dependency> 95 <groupId>org.springframework.boot</groupId> 96 <artifactId>spring-boot-starter-test</artifactId> 97 <scope>test</scope> 98 </dependency> 99 </dependencies> 100 101 <profiles> 102 <profile> 103 <id>local</id> 104 <properties> 105 <profile.active>local</profile.active> 106 </properties> 107 <activation> 108 <activeByDefault>true</activeByDefault> 109 </activation> 110 </profile> 111 <profile> 112 <id>dev</id> 113 <properties> 114 <profile.active>dev</profile.active> 115 </properties> 116 <activation> 117 <activeByDefault>true</activeByDefault> 118 </activation> 119 </profile> 120 </profiles> 121 <build> 122 123 124 125 126 <resources> 127 <resource> 128 <directory>src/main/resources</directory> 129 <excludes> 130 <exclude>application-local.properties</exclude> 131 <exclude>application-dev.properties</exclude> 132 </excludes> 133 <includes> 134 <include>application-${profile.active}.properties</include> 135 </includes> 136 </resource> 137 </resources> 138 <plugins> 139 <!-- <plugin> 140 <groupId>org.springframework.boot</groupId> 141 <artifactId>spring-boot-maven-plugin</artifactId> 142 <configuration> 143 <mainClass>com.sharp.forward.SharpServiceApplication.java</mainClass> 144 </configuration> 145 </plugin> --> 146 <!-- 打包插件 --> 147 <plugin> 148 <groupId>org.apache.maven.plugins</groupId> 149 <artifactId>maven-jar-plugin</artifactId> 150 <version>2.6</version> 151 <configuration> 152 <archive> 153 <manifest> 154 <!--指定main入口--> 155 <mainClass>com.sharp.forward.SharpServiceApplication.java</mainClass> 156 <addClasspath>true</addClasspath> 157 <classpathPrefix>../lib/</classpathPrefix> 158 </manifest> 159 <manifestEntries> 160 <Class-Path>../conf/</Class-Path> 161 </manifestEntries> 162 </archive> 163 <excludes> 164 <exclude>config/**</exclude> 165 </excludes> 166 </configuration> 167 </plugin> 168 <plugin> 169 <artifactId>maven-assembly-plugin</artifactId> 170 <configuration> 171 <descriptors> 172 <descriptor>src/main/resources/assembly.xml</descriptor> 173 </descriptors> 174 </configuration> 175 <executions><!--执行器 mvn assembly:assembly--> 176 <execution> 177 <id>make-assembly</id><!--名字任意 --> 178 <phase>package</phase><!-- 绑定到package生命周期阶段上 --> 179 <goals> 180 <goal>single</goal><!-- 只运行一次 --> 181 </goals> 182 </execution> 183 </executions> 184 </plugin> 185 186 </plugins> 187 </build> 188 189 190 </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整合后如下“
1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4 <modelVersion>4.0.0</modelVersion> 5 <parent> 6 <groupId>com.sharp</groupId> 7 <artifactId>sharp-pom</artifactId> 8 <version>0.0.1-SNAPSHOT</version> 9 </parent> 10 <artifactId>sharp-service</artifactId> 11 <packaging>jar</packaging> 12 13 <name>sharp-sevice</name> 14 <description>Demo project for Spring Boot</description> 15 <dependencies> 16 <!-- <dependency> 17 <groupId>org.springframework.boot</groupId> 18 <artifactId>spring-boot-starter-amqp</artifactId> 19 </dependency> 20 <dependency> 21 <groupId>org.springframework.boot</groupId> 22 <artifactId>spring-boot-starter-data-mongodb</artifactId> 23 </dependency> 24 <dependency> 25 <groupId>org.springframework.boot</groupId> 26 <artifactId>spring-boot-starter-data-redis</artifactId> 27 </dependency> --> 28 <dependency> 29 <groupId>org.springframework.boot</groupId> 30 <artifactId>spring-boot-starter-web</artifactId> 31 </dependency> 32 <dependency> 33 <groupId>com.alibaba</groupId> 34 <artifactId>druid</artifactId> 35 </dependency> 36 <dependency> 37 <groupId>org.springframework</groupId> 38 <artifactId>spring-jdbc</artifactId> 39 </dependency> 40 <dependency> 41 <groupId>com.sharp</groupId> 42 <artifactId>sharp-entity</artifactId> 43 <version>${project.parent.version}</version> 44 </dependency> 45 <dependency> 46 <groupId>com.sharp</groupId> 47 <artifactId>sharp-common</artifactId> 48 <version>${project.parent.version}</version> 49 </dependency> 50 <dependency> 51 <groupId>com.sharp</groupId> 52 <artifactId>sharp-mapper</artifactId> 53 <version>${project.parent.version}</version> 54 </dependency> 55 <dependency> 56 <groupId>com.sharp</groupId> 57 <artifactId>sharp-service-api</artifactId> 58 <version>${project.parent.version}</version> 59 </dependency> 60 <dependency> 61 <groupId>org.mybatis.spring.boot</groupId> 62 <artifactId>mybatis-spring-boot-starter</artifactId> 63 </dependency> 64 <dependency> 65 <groupId>mysql</groupId> 66 <artifactId>mysql-connector-java</artifactId> 67 </dependency> 68 <dependency> 69 <groupId>org.apache.zookeeper</groupId> 70 <artifactId>zookeeper</artifactId> 71 </dependency> 72 <dependency> 73 <groupId>com.101tec</groupId> 74 <artifactId>zkclient</artifactId> 75 <version>0.9</version> 76 </dependency> 77 <!-- https://mvnrepository.com/artifact/com.gitee.reger/spring-boot-starter-dubbo --> 78 <!-- <dependency> 79 <groupId>com.gitee.reger</groupId> 80 <artifactId>spring-boot-starter-dubbo</artifactId> 81 <version>1.1.1</version> 82 </dependency> 83 --> 84 <dependency> 85 <groupId>com.alibaba</groupId> 86 <artifactId>dubbo</artifactId> 87 <exclusions> 88 <exclusion> 89 <groupId>org.springframework</groupId> 90 <artifactId>spring</artifactId> 91 </exclusion> 92 </exclusions> 93 </dependency> 94 <dependency> 95 <groupId>org.springframework.boot</groupId> 96 <artifactId>spring-boot-starter-test</artifactId> 97 <scope>test</scope> 98 </dependency> 99 </dependencies> 100 101 <profiles> 102 <profile> 103 <id>local</id> 104 <properties> 105 <profile.active>local</profile.active> 106 </properties> 107 <activation> 108 <activeByDefault>true</activeByDefault> 109 </activation> 110 </profile> 111 <profile> 112 <id>dev</id> 113 <properties> 114 <profile.active>dev</profile.active> 115 </properties> 116 <activation> 117 <activeByDefault>true</activeByDefault> 118 </activation> 119 </profile> 120 </profiles> 121 <build> 122 <!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 --> 123 <resources> 124 <resource> 125 <directory>src/main/java</directory> 126 <includes> 127 <include>**/*.yml</include> 128 <include>**/*.properties</include> 129 <include>**/*.xml</include> 130 </includes> 131 <filtering>false</filtering> 132 </resource> 133 <resource> 134 <directory>src/main/resources</directory> 135 <excludes> 136 <exclude>application-local.properties</exclude> 137 <exclude>application-dev.properties</exclude> 138 </excludes> 139 <includes> 140 <include>**/*.yml</include> 141 <include>application.properties</include> 142 <include>application-${profile.active}.properties</include> 143 <include>**/*.xml</include> 144 </includes> 145 <filtering>false</filtering> 146 </resource> 147 </resources> 148 <plugins> 149 <!-- <plugin> 150 <groupId>org.springframework.boot</groupId> 151 <artifactId>spring-boot-maven-plugin</artifactId> 152 <configuration> 153 <mainClass>com.sharp.forward.SharpServiceApplication.java</mainClass> 154 </configuration> 155 </plugin> --> 156 <!-- 打包插件 --> 157 <plugin> 158 <groupId>org.apache.maven.plugins</groupId> 159 <artifactId>maven-jar-plugin</artifactId> 160 <version>2.6</version> 161 <configuration> 162 <archive> 163 <manifest> 164 <!--指定main入口--> 165 <mainClass>com.sharp.forward.SharpServiceApplication.java</mainClass> 166 <addClasspath>true</addClasspath> 167 <classpathPrefix>../lib/</classpathPrefix> 168 </manifest> 169 <manifestEntries> 170 <Class-Path>../conf/</Class-Path> 171 </manifestEntries> 172 </archive> 173 <excludes> 174 <exclude>config/**</exclude> 175 </excludes> 176 </configuration> 177 </plugin> 178 <plugin> 179 <artifactId>maven-assembly-plugin</artifactId> 180 <configuration> 181 <descriptors> 182 <descriptor>src/main/resources/assembly.xml</descriptor> 183 </descriptors> 184 </configuration> 185 <executions><!--执行器 mvn assembly:assembly--> 186 <execution> 187 <id>make-assembly</id><!--名字任意 --> 188 <phase>package</phase><!-- 绑定到package生命周期阶段上 --> 189 <goals> 190 <goal>single</goal><!-- 只运行一次 --> 191 </goals> 192 </execution> 193 </executions> 194 </plugin> 195 196 </plugins> 197 </build> 198 199 200 </project>
重新构建编译,仍正常启动,ok!
spingboot2.0外部引入xml配置文件时找不到文件等报错
原文:https://www.cnblogs.com/xiaoyao-001/p/10095417.html