Summary:

When they fight barbarian units, your less well-trained units will gain experience points. However, any unit that has already acquired 30 XPs (or has exchanged that many for promotions) no longer gains XPs from fighting barbarians.