当前位置: 首页 > 知识库问答 >
问题:

我无法在windows上运行spring启动jar

百里沛
2023-03-14

我开始开发projet,现在使用windows。基本上,我可以使用maven生成一个Jar文件,但当我尝试运行Jar文件时,它并不好用。听起来好像没有找到hibernate属性。

我的错误:

2017-01-15 16:03:12.454  INFO 19012 --- [main] org.hibernate.Version                    : 
    HHH000412: Hibernate Core    {5.0.11.Final} 
2017-01-15 16:03:12.473  INFO 19012 --- [main] org.hibernate.cfg.Environment            : 
    HHH000206: hibernate.properties not found 
2017-01-15 16:03:12.480  INFO 19012 --- [main] org.hibernate.cfg.Environment            : 
    HHH000021: Bytecode provider name : javassist 
2017-01-15 16:03:13.122  INFO 19012 --- [main] o.hibernate.annotations.common.Version   : 
    HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 
2017-01-15 16:03:16.112  WARN 19012 --- [main] o.h.e.j.e.i.JdbcEnvironmentInitiator     : 
    HHH000342: Could not obtain connection to query metadata : Access denied for user root 'root'@'localhost' (using password: YES) 
2017-01-15 16:03:16.135  WARN 19012 --- [main] ationConfigEmbeddedWebApplicationContext : 
    Exception encountered during context initialization - cancelling refresh attempt: 
        org.springframework.beans.factory.BeanCreationException: 
            Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: 
                Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: 
                    Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] 
2017-01-15 16:03:16.149  INFO 19012 --- [main] o.apache.catalina.core.StandardService   : 
    Stopping service Tomcat    
2017-01-15 16:03:16.234  WARN 19012 --- [main] o.s.boot.SpringApplication               : 
    Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]:    
        BeanPostProcessor before instantiation of bean  failed; nested exception is org.springframework.beans.factory.BeanCreationException: 
            Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': 
                Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
                    No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' is defined)
2017-01-15 16:03:16.275 ERROR 19012 --- [main] o.s.boot.SpringApplication               : 
    Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: 
        Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: 
            Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583) ~[spring-beans-4.3.3.RELEASE.jar !/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.3.3.RELEASE.jar!/:    4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1076) ~[spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:851) ~[spring-context-4.3.3.RELEASE.jar!/:4 .3.3.RELEASE]
                at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
                at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
                at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
                at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
                at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
                at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
                at com.SimonSaysApplication.main(SimonSaysApplication.java:32) [classes!/:0.0.1-SNAPSHOT]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_77]
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_77]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_77]
                at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_77]
                at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [simonsays-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
                at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [simonsays-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
                at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [simonsays-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
                at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [simonsays-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] 
            Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:264) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:228) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847) ~[hibernate-entitymanager-5.0.11.Final.jar!/:5.0.11.Fin al]
                at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874) ~[hibernate-entitymanager-5.0.11.Final.jar!/:5.0.11.Final]
                at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4 .3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.3.RE LEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373) ~[spring-orm-4.3.3.RELEASE.jar!/:4 .3.3.RELEASE]
                at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362) ~[spring-orm-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642) ~[spring-beans-4.3.3.RELEASE. jar!/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579) ~[spring-beans-4.3.3.RELEASE.jar !/:4.3.3.RELEASE]            
                ... 24 common frames omitted 
            Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
                at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:254) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]            
                ... 40 common frames omitted

我的Hibernate配置位于\src\main\Resources\application.properties

db.driver = com.mysql.jdbc.Driver
db.url = jdbc:mysql://localhost:3306/simonsays?characterEncoding=UTF-8&useSSL=false
db.username = root
db.password = 1234

#Hibernate configuration
hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
hibernate.show_sql = false
hibernate.hbm2ddl.auto = update
entitymanager.packagesToScan = com

我怎么处理?

[更新]

使用mvn spring boot运行时,我可能会得到不同的结果:run

>

  • 代替旧错误,我可以看到我的数据库,但当它打开tomcat时,我遇到了一个奇怪的错误:

    说明:

    配置为在端口444上侦听的Tomcat连接器无法启动。端口可能已在使用中,或者连接器可能配置错误。

    行动:

    验证连接器的配置,识别并停止侦听端口444的任何进程,或将此应用程序配置为侦听另一个端口。

  • 共有3个答案

    杜英叡
    2023-03-14

    好的,我想我已经解决了这个问题:

    首先,我试图构建一个jar来运行,但由于没有加载我的配置,所以效果不好,然后我使用以下方法得到了更好的结果:

    mvn spring-boot:run
    

    但我得到了一个tomcat错误,因为SSL,然后我只需要禁用SSL并像往常一样将端口更改为8080,它就可以运行了

    白祺然
    2023-03-14

    您的日志显示db正在拒绝连接:

      HHH000342: Could not obtain connection to query metadata : 
    Access denied for user root 'root'@'localhost' (using password: YES) 
    

    因此,请尝试使用您在应用程序中提供的凭据点击DB,如果正确,请将其与127.0.0.1或本地系统的IP绑定,而不是像Alex Roig所说的那样localhost。

    孔飞翔
    2023-03-14

    看起来您的数据库拒绝了连接,因为使用r“root”@“localhost”(使用密码:YES)拒绝了访问。您是否可以尝试使用MySQL CLI或MySQL Workbench使用与应用程序中相同的凭据登录到您的数据库。属性?

     类似资料:
    • 在 Windows 上执行命令将返回以下结果: 运行诊断程序会产生以下结果:

    • 我下面介绍了spring的RESTAPI,但我无法让它在tomcat服务器上运行(尝试了tomcat 7和9)。在eclipse中,我确实以- 编辑 尝试在项目上安装mvn,然后java-jarproject.jar 编辑2 我将项目导出到一个可运行的jar(并将所需的库打包到生成的jar中),但是 提供 编辑3 我没有删除我的m2,因为那里有很多东西,但我现在通过eclipse的spring工具

    • java 15.0.2 2021-01-19 java(TM)SE运行时环境(构建15.0.2 7-27)java热点(TM)64位服务器虚拟机(构建15.0.2 7-27,混合模式,共享)sonarqube-8.7.0.41497

    • 在64位windows 10上运行,我从他们的64位windows网站下载了Spring sts 3.8.2,并安装了JDK 1.8.0_111和JRE 1.8.0_111。 JDK被添加到环境变量PATH。 当运行STS时,我最终会收到以下错误消息: 我也不明白的是,在任务管理器中,STS被标记为32位版本,尽管我下载了64位版本: 这就是我在java版本中得到的: 知道这是怎么回事吗?

    • 我已经在Windows Server 2019上安装了Minikube与Docker一起使用。但是,当我尝试从开始时,它显示以下错误: 启动超虚拟机失败。运行“minikube delete”可能会修复它:加载现有主机时出错。 Hyper-V\Start-VM minikube 无法修复此问题。 当我以

    • Invoke-Neo4j:无法确定E:\neo4j处的安装版本 在行:1字符:175 尝试{unblock-file-path'e:\neo4j\bin\neo4j-management*.*'-erroraction'silentlycontinue'>catch<>;import-module null