我正在使用JHipster来构建一个java应用程序。
我单独创建了一个mysql数据库,我想我已经将它的连接信息粘贴到pom.xml
文件的liquibase插件部分(注意:那是一个虚拟的IP),将它连接到应用程序:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
<diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://108.10.10.10:3306/calc</url>
<defaultSchemaName>calc</defaultSchemaName>
<username>root</username>
<password>password</password>
<referenceUrl>hibernate:spring:com.mycompany.myapp.domain?dialect=org.hibernate.dialect.MySQLInnoDBDialect</referenceUrl>
<verbose>true</verbose>
<logging>debug</logging>
</configuration>
<dependencies>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.2-GA</version>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate4</artifactId>
<version>${liquibase-hibernate4.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
</plugin>
当我用:
运行应用程序时mvn spring-boot:run
...它完成npm
和bower
任务就好了,但是当需要执行java方面的事情时,它会因为一个大错误而失败:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building calc 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:1.2.5.RELEASE:run (default-cli) > test-compile @ calc >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-versions) @ calc ---
[INFO]
[INFO] --- maven-processor-plugin:2.2.4:process (process) @ calc ---
[WARNING] diagnostic: warning: The following options were not recognized by any processor: '[mapstruct.defaultComponentModel, mapstruct.suppressGeneratorTimestamp]'
[INFO]
[INFO] --- yeoman-maven-plugin:0.4:build (run-grunt) @ calc ---
[INFO] node version :
v0.12.7
[INFO] npm version :
2.11.3
[INFO] --------------------------------------
[INFO] NPM INSTALL
[INFO] --------------------------------------
[INFO] bower version :
1.4.1
[INFO] --------------------------------------
[INFO] BOWER INSTALL --NO-COLOR
[INFO] --------------------------------------
bower angular-cookies extra-resolution Unnecessary resolution: angular-cookies#1.4.0
[INFO] grunt version :
grunt-cli v0.1.13
grunt v0.4.5
[INFO] --------------------------------------
[INFO] GRUNT COMPASS:SERVER --FORCE
[INFO] --------------------------------------
Running "compass:server" (compass) task
unchanged src/main/scss/main.scss
Compilation took 0.171s
Done, without errors.
Execution Time (2015-07-17 17:28:55 UTC)
loading tasks 64ms ▇▇▇▇ 7%
compass:server 812ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 93%
Total 877ms
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ calc ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] Copying 11 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ calc ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 85 source files to /Users/kristianalexander/Documents/code/java/calc/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ calc ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ calc ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:1.2.5.RELEASE:run (default-cli) < test-compile @ calc <<<
[INFO]
[INFO] --- spring-boot-maven-plugin:1.2.5.RELEASE:run (default-cli) @ calc ---
[INFO] Attaching agents: []
Listening for transport dt_socket at address: 5005
[INFO] com.mycompany.myapp.Application - Starting Application on Kristians-MacBook-Pro.local with PID 9490 (/Users/kristianalexander/Documents/code/java/calc/target/classes started by kristianalexander in /Users/kristianalexander/Documents/code/java/calc)
[DEBUG] com.mycompany.myapp.Application - Running with Spring Boot v1.2.5.RELEASE, Spring v4.1.7.RELEASE
[DEBUG] org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
[DEBUG] com.mycompany.myapp.config.AsyncConfiguration - Creating Async Task Executor
[DEBUG] com.mycompany.myapp.config.MetricsConfiguration - Registering JVM gauges
[INFO] com.mycompany.myapp.config.MetricsConfiguration - Initializing Metrics JMX reporting
[DEBUG] com.mycompany.myapp.config.DatabaseConfiguration - Configuring Datasource
[ERROR] org.springframework.boot.context.embedded.tomcat.TomcatStarter - Error starting Tomcat context: org.springframework.beans.factory.BeanCreationException
[WARN] org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) [spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) [spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) [spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) [spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at com.mycompany.myapp.Application.main(Application.java:72) [classes/:na]
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:98) ~[spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:75) ~[spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:378) ~[spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:155) ~[spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:157) [spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) [spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
... 5 common frames omitted
.... 115,000多行错误......
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
... 139 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:213)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:297)
... 156 more
答案 0 :(得分:2)
liquibase连接信息仅用于数据库重构。
实际应用程序的DB(开发)连接信息应设置为:
src/main/resources/config/application-dev.yml
一旦我更新了它,它启动时没有错误。
连接信息的文档:http://jhipster.github.io/creating_an_app.html
注意:
pom.xml
中填写liquibase配置并在application-dev.yml
文件中设置配置。mvn spring-boot:run