我有一个Spring Boot应用程序,我们在一些小型服务器上安装我们的产品。它一直有效。今天晚上我们将它安装在我们的一台服务器上,但没有启动。
每个服务器都是来自普通图像的图像,因此操作系统是相同的。
当我们启动.jar时,我们得到了:
Oct 05, 2016 11:16:45 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Oct 05, 2016 11:16:45 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.5.5
Oct 05, 2016 11:16:46 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring embedded WebApplicationContext
Oct 05, 2016 11:17:03 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Tomcat
这是我们关于hibernate
的application.properties# Username and password
spring.datasource.username = parkuser
spring.datasource.password = xxxxxxxxxxxxxxxxxxxxxx
spring.datasource.url= jdbc:mysql://xxxxxxxxxxxxxxxxxxxxxxxxx:3306/SMARTPARK?useSSL=false
# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
spring.jpa.show-sql = false
# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
spring.jpa.hibernate.ddl-auto = update
# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext
在我们的pom.xml中,我们有
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
</parent>
<dependencies>
<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>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
<version>1.3.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
这是我们的StartServer.class
@SpringBootApplication
@EnableScheduling
public class StartServer extends SpringBootServletInitializer{
public static void main(String[] args){
SpringApplication.run(StartServer.class, args);
}
@Bean
public HibernateJpaSessionFactoryBean sessionFactory() {
return new HibernateJpaSessionFactoryBean();
}
}
我无法理解为什么同一个jar在一个设备中工作并在另一个中出现这个错误而且我无法理解哪个是错误...
答案 0 :(得分:1)
我遇到了同样的问题。然后在清理我的本地maven存储库后,应用程序启动并运行。清理您当地的maven仓库(由于依赖性损坏),然后再试一次!
答案 1 :(得分:0)
我不是百分百肯定,但我会替换它:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
....
</dependency>
有了这个:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
...
</dependencies>
见下面的例子:
<groupId>org.springframework</groupId>
<artifactId>gs-relational-data-access</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
</parent>
<properties>
....
</properties>
<dependencies>
<dependency>
....
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>[5,]</version>
</dependency>
</dependencies>
或者,只需这样做:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>your version</version>
</dependency>
答案 2 :(得分:0)
如果您错过了项目中的application.properties文件,那么您还将面临此类问题。检查它在您的类路径中是否可用。