spring boot项目部署Linux时,运行tomcat启动报错 Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
1 2 3 4 5 6 7 8 9 10 11 12 Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2019 -06 -09 20 :32 :20.318 ERROR 23315 --- [ost-startStop-1 ] o.s.b.d.LoggingFailureAnalysisReporter :*************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class
查看linux服务器中/webapps/ROOT/WEB-INF/classes下的项目文件,发现不存在application.properties文件
设置由于pom文件里面配置< resources >时未设置打包.properties文件,导致tomcat读取不到.properties文件的配置信息。
在< resources >中加入扫描.properties文件即可 注意往下看
1 2 3 4 5 6 <resource > <directory > src/main/resources</directory > <includes > <include > **/*.properties</include > </includes > </resource >
如果只配置.properties文件可能会导致进入tomcat运行成功后访问项目静态资源文件报错。
异常:This application has no explicit mapping for /error, so you are seeing this as a fallback.
javax.servlet.ServletException: Circular view path [login]: would dispatch back to the current handler URL [/login] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
此时需要设置扫描src/main/resources下的全部文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 <build > <finalName > jfkj-crm</finalName > <resources > <resource > <directory > src/main/java</directory > <includes > <include > **/*.xml</include > </includes > </resource > <resource > <directory > src/main/resources</directory > <includes > <include > **/*.*</include > </includes > </resource > </resources > <plugins > <plugin > <groupId > org.springframework.boot</groupId > <artifactId > spring-boot-maven-plugin</artifactId > </plugin > </plugins > </build >