spring-boot之Spring Boot排除了在Maven构建期间连接到数据库的问题
lhb25
阅读:55
2025-06-02 22:19:02
评论:0
我有一种情况,我想在AWS中部署Spring Boot应用程序,但我只想忽略本地构建期间内部发生的数据库连接,因为我没有任何测试类,也不想包含H2数据库。可以建立要在AWS中部署的jar文件而无需连接到AWS数据库吗?
Application.properties
# ===============================
# = DATA SOURCE
# ===============================
# Set here configurations for the database connection
# Connection url for the database "netgloo_blog"
spring.datasource.url = jdbc:mysql://localhost:3306/auto_journey
# Username and password
spring.datasource.username = root
spring.datasource.password =auto123
# Keep the connection alive if idle for a long time (needed in production)
#spring.datasource.testWhileIdle = true
#spring.datasource.validationQuery = SELECT 1
# ===============================
# = JPA / HIBERNATE
# ===============================
# Use spring.jpa.properties.* for Hibernate native properties (the prefix is
# stripped before adding them to the entity manager).
# Show or not log for each sql query
spring.jpa.show-sql = true
# 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.MySQL5Dialect
server.servlet.context-path=/autofinance
server.port=9090
spring.mvc.static-path-pattern=/resources/**
请您参考如下方法:
将其包含在pom.xml中以解决该问题。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。



