org.springframework.boot.orm.jpa

Annotation Type EntityScan



  • @Target(value=TYPE)
     @Retention(value=RUNTIME)
     @Documented
     @Import(value=org.springframework.boot.orm.jpa.EntityScanRegistrar.class)
    public @interface EntityScan
    Configures the LocalContainerEntityManagerFactoryBean to scan for entity classes in the classpath. This annotation provides an alternative to manually setting LocalContainerEntityManagerFactoryBean.setPackagesToScan(String...) and is particularly useful if you want to configure entity scanning in a type-safe way, or if your LocalContainerEntityManagerFactoryBean is auto-configured.

    A LocalContainerEntityManagerFactoryBean must be configured within your Spring ApplicationContext in order to use entity scanning. Furthermore, any existing packagesToScan setting will be replaced.

    One of basePackageClasses(), basePackages() or its alias value() may be specified to define specific packages to scan. If specific packages are not defined scanning will occur from the package of the class with this annotation.

    Author:
    Phillip Webb
    • Element Detail

      • value

        public abstract String[] value
        Alias for the basePackages() attribute. Allows for more concise annotation declarations e.g.: @EntityScan("org.my.pkg") instead of @EntityScan(basePackages="org.my.pkg").
        Returns:
        the base packages to scan
        Default:
        {}
      • basePackages

        public abstract String[] basePackages
        Base packages to scan for annotated entities. value() is an alias for (and mutually exclusive with) this attribute.

        Use basePackageClasses() for a type-safe alternative to String-based package names.

        Returns:
        the base packages to scan
        Default:
        {}
      • basePackageClasses

        public abstract Class<?>[] basePackageClasses
        Type-safe alternative to basePackages() for specifying the packages to scan for annotated entities. The package of each class specified will be scanned.

        Consider creating a special no-op marker class or interface in each package that serves no purpose other than being referenced by this attribute.

        Returns:
        classes from the base packages to scan
        Default:
        {}

Copyright © 2015 Pivotal Software, Inc.. All rights reserved.