All language subtitles for 008 Component Scanning - Overview_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

-: This video will cover Component Scanning with Spring.

Spring will scan your Java classes

or special annotations such as @Component,

and it'll automatically register the beans

in the Spring container.

Let's look at some Java source code here.

So in our project, we currently have

this Spring core demo application.

That's our main Spring Boot application class

that was created by the Spring Initializer.

We also have our RestController that we created

in an earlier video, called DemoController.

Now, in that Spring core demo application,

the one that was created by the Spring Initializer,

note here that it does an import on Spring Boot Application.

So this enables auto configuration, component scanning

and additional configuration with Spring Boot.

And really behind the scenes, this annotation is composed

of the following annotations, enable auto

configuration, component scan and configuration.

So, a bit more here in these annotations.

The @SpringBootApplication is composed

of the following annotations.

@EnableAutoConfiguration enables Spring Boot's

auto configuration support,

@ComponentScan enables component scanning

of the current package and also

recursively scans the sub-packages,

and the @Configuration annotation is able to

register extra beans with the @Bean annotation

or import other configuration classes.

I'll show you some examples

of the configuration annotation a bit later in the course.

And now back to our Java Source Code.

So we know the information here

about the Spring Boot application.

Next we have this Spring application.

And so this allows us to bootstrap our Spring

Boot application, and then we give a reference here

to the actual name of our class,

in this case, SpringcoredemoApplication.

So behind the scenes this will create the application

context, register all the beans, and also start

the embedded server such as Tomcat, et cetera, by default.

Now, a bit more here on component scanning.

By default, Spring Boot starts component scanning

from the same package as your main Spring Boot application.

And also it scans the sub-packages recursively.

This implicitly defines a base search package

that you can make use of.

So it allows you to leverage default component scanning

without having to explicitly referencing

the base package name.

So here's a diagram to kind of pull this together.

We have our Main Spring Boot application class.

It automatically component scans

the package and sub-packages.

We can create any other sub-packages that we want.

We can give these sub-packages any name,

and then it scans everything in core luv2code.springcoredemo

package, and any sub-packages.

So basically it starts scanning

at the Main Spring Boot application class level

and then all sub-packages underneath that.

Now, a common pitfall when you're making use

of Spring Boot, you may say,

Hey, I'm going to use different packages

and move things around and change things up or whatever.

Here's an example.

So we have our Spring Core Demo, that's the package

of our Main Spring Boot application class.

Then, you may create other packages outside of that.

So using this example here of demo utils,

notice here that it's outside of our Spring Core Demo.

And so by default,

Spring Boot will not component scan these packages.

It will only scan the package

of the Main Spring Boot application class and sub-packages.

So this is very important.

So, the default scanning works fine

if everything is under com.luv2code.springcoredemo.

But what about my other packages?

Like I want to use some different names or whatever

like com.luv2code.util, or org.acme.cart,

or edu.cmu.spirit racing systems.

How will this kind of work out,

or how can I configure this accordingly?

Well, what you can do is,

in your Spring Boot application annotation

then you can tell it to scan base packages.

So, here I'm going to explicitly list

the base packages to scan.

And you simply give a comma'd limited list

of those packages that you want Spring Boot to scan.

So, give our com.luv2code.sprincoredemo,

and then luv2code.util, org.acme.cart, edu.cmu.srs.

All right, so this is all really good stuff.

We're going to move into the next video,

we're going to write the code.

I'll show you how to make use

of default scanning, and also I'll show you how

to manually list the actual package scanning.

I'll see ya in the next video.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.