In cases like this you should be aware that tax treaties may exist and that countries are generally willing to enter into them. Their purpose is to help prevent double taxation. Tax treaties often times give you a better tax rate than even being a resident of the countries in question! (For instance, the Italy to US tax rate is lower than simply doing business in many United States)
This should guide your google search, here is something I found for Germany/Spain
http://tmagazine.ey.com/wp-content/uploads/2011/03/2011G_CM2300_Spain-Germany-sign-new-tax-treaty.pdf
It appears that the dividend tax rate under that treaty is 5% , to my understanding, the income tax rates are often multiples higher! I read that spain's income tax rate is 18%
So what I would do is see if there is the possibility of deferring taxes in the lower tax jurisidiction and then doing a large one time dividend when conveninet. But Germany isn't really known for its low taxes, being a Federal Republic, the taxes are levied by both the states and the federal government. Look to see if your business structure can avoid being taxed as the entity level: ie. your business' earnings are always distributed to the owners - which are not germany citizens or residents - as dividends.
So this way you avoid Germany's 15% federal corporate tax, and you avoid Spain's 18% income tax, and instead get Spanish dividends at 5% tax.
Anyway, contact a tax attorney to help interpret the use of the regulations, but this is the frame of mind you should be thinking in. Because it looks like spain is willing to do a tax credit if you pay taxes in germany, several options here to lower your tax footprint.