Can I ask..something about Spring Xml code completion?

Hello. I'm Korean Student.
I'm a beginner of IntelliJ.

I just want to know How to use efficiently code completion in XML files when I make Spring Bean Tags.

For exmaple, When I use IntelliJ, I have to type many package name, again and again..and Finally I can type Class name.
But Eclipse (with STS), I just type Class name, then Content assist show classes..

Is any other convenient way for IntelliJ?

I googled many things and Spent much TIme.
I can't find it. Help me..(cry)

스크린샷 2014-07-18 오후 6.28.50.png
스크린샷 2014-07-18 오후 6.19.36.png
Comment actions Permalink

You should not need to type the package name. You can just type the class name and use autocomplete to suggest classes.

If you invoke code completion (Ctrl+Space) on the class attribute, the suggestion window will initially show packages:

(Click on images to see larger)

But if you invoke Code completion (Ctrl+Space) a second time, classes will show, and the list will narrow down as you type:

So that you do not have to invoke auto complete twice, you can instead invoke the "Class Name Completion" action via Ctrl+Alt+Space right from the start.

The easiest way to create a bean definition, is to:

1) Use the Code Generation action (Alt+Insert) ans select "Spring Bean":


This will give you the basic tag skeleton with your cursor in the class name attribute:
2) Use code completion (Ctrl+Space) twice or Class Name Completion (Ctrl+Alt+Space) to complete the name of the class you want.

3) Upon selecting it and hitting enter, IDEA will enter the fully qualified name. Notice the red box tells you you are still in a template completion field.
(Note that the bean I'm selecting here is from a "hello World" like Spring application I have abd use for Spring examples.)

4) Hit enter to confirm the fully qualified name, and the cursor will move to the id attribute with suggested names:
You can either use one of the suggested names, or enter your own. Hit Enter once you are done.
In this screenshot, the bean class is underlined in red because some required properties (i.e. setters annotated with the @Required annotation) have not been set.

5) You can then again use the Code Generation to set the properties. With your cursor inside the bean definition element, hit Alt+Insert and select "Properties" (Note that you can use your mouse, the arrow keys or start typing the word Properties to inline search for and select the "Properties" option):
IDEA will show a list of all the properties in the bean.
Select one or more of the properties you want to set and click OK. IDEA will insert all the properties tags. (As a side note, the order you select the properties by using the Ctrl Key and the mouse will be the order the <property> elements appear in the <bean> element.) For any non-primitive properties, idea will add a ref tag. For any primitive properties for which there is a bean defined that satisfies the property type, IDEA will enter a 'ref' attribute; otherwise it enters a value attribute for primitive properties. For the ref attributes, it will suggest bean names. Once you select (or type one) and hit enter, it moves to the next property.

I hope that helps answer your questions.

Comment actions Permalink

Ah.. Thanks a Million.

As soon as I saw Your comment.

I did it . But I realized something wrong with my IntelliJ.

Because I can't see any generate List, class and stuff..
So, I was searching the difference about Community version and Ultimate Edition...

And Now, I think My IntelliJ is Wrong. Because My version is community....(cry)..

Anyway Thanks for Your kind comment.
I'm considering purchase Ultimate Edition.

Your comment is very helpful and impressing.

Comment actions Permalink

Glad I could help. You are correct that you need the Ultimate Edition to have Spring support. Keep in mind that JetBrains does offer Academic licenses for IntelliJ IDEA Ultimate at a discount. (50% off as compared to a conventional Personal License).


Please sign in to leave a comment.