Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
d0811b48
Commit
d0811b48
authored
Dec 31, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Disable Hibernate entity scanning for default JPA setup"
Closes gh-15565
parent
510a8e2e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
15 deletions
+17
-15
HibernateProperties.java
...ework/boot/autoconfigure/orm/jpa/HibernateProperties.java
+8
-6
HibernatePropertiesTests.java
.../boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java
+9
-9
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateProperties.java
View file @
d0811b48
...
...
@@ -27,6 +27,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import
org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
;
import
org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
...
...
@@ -34,13 +35,14 @@ import org.springframework.util.StringUtils;
* Configuration properties for Hibernate.
*
* @author Stephane Nicoll
* @author Artsiom Yudovin
* @since 2.1.0
* @see JpaProperties
*/
@ConfigurationProperties
(
"spring.jpa.hibernate"
)
public
class
HibernateProperties
{
private
static
final
String
DISABLED_SCANNER_CLASS
=
"org.hibernate.boot.archive.scan.internal.DisabledScanner"
;
private
final
Naming
naming
=
new
Naming
();
/**
...
...
@@ -96,7 +98,7 @@ public class HibernateProperties {
HibernateSettings
settings
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>(
existing
);
applyNewIdGeneratorMappings
(
result
);
apply
Archive
Scanner
(
result
);
applyScanner
(
result
);
getNaming
().
applyNamingStrategies
(
result
);
String
ddlAuto
=
determineDdlAuto
(
existing
,
settings:
:
getDdlAuto
);
if
(
StringUtils
.
hasText
(
ddlAuto
)
&&
!
"none"
.
equals
(
ddlAuto
))
{
...
...
@@ -123,10 +125,10 @@ public class HibernateProperties {
}
}
private
void
apply
Archive
Scanner
(
Map
<
String
,
Object
>
result
)
{
if
(!
result
.
containsKey
(
AvailableSettings
.
SCANNER
)
)
{
result
.
put
(
AvailableSettings
.
SCANNER
,
"org.hibernate.boot.archive.scan.internal.DisabledScanner"
);
private
void
applyScanner
(
Map
<
String
,
Object
>
result
)
{
if
(!
result
.
containsKey
(
AvailableSettings
.
SCANNER
)
&&
ClassUtils
.
isPresent
(
DISABLED_SCANNER_CLASS
,
null
))
{
result
.
put
(
AvailableSettings
.
SCANNER
,
DISABLED_SCANNER_CLASS
);
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java
View file @
d0811b48
...
...
@@ -125,7 +125,15 @@ public class HibernatePropertiesTests {
}
@Test
public
void
useArchiveScanner
()
{
public
void
scannerUsesDisabledScannerByDefault
()
{
this
.
contextRunner
.
run
(
assertHibernateProperties
(
(
hibernateProperties
)
->
assertThat
(
hibernateProperties
).
containsEntry
(
AvailableSettings
.
SCANNER
,
"org.hibernate.boot.archive.scan.internal.DisabledScanner"
)));
}
@Test
public
void
scannerCanBeCustomized
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.jpa.properties.hibernate.archive.scanner:org.hibernate.boot.archive.scan.internal.StandardScanner"
)
.
run
(
assertHibernateProperties
((
hibernateProperties
)
->
assertThat
(
...
...
@@ -133,14 +141,6 @@ public class HibernatePropertiesTests {
"org.hibernate.boot.archive.scan.internal.StandardScanner"
)));
}
@Test
public
void
defaultArchiveScanner
()
{
this
.
contextRunner
.
run
(
assertHibernateProperties
(
(
hibernateProperties
)
->
assertThat
(
hibernateProperties
).
containsEntry
(
AvailableSettings
.
SCANNER
,
"org.hibernate.boot.archive.scan.internal.DisabledScanner"
)));
}
@Test
public
void
defaultDdlAutoIsNotInvokedIfPropertyIsSet
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.jpa.hibernate.ddl-auto=validate"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment