When it comes to the check of the invariance of the Lagrangian of the Dirac equation under local $U(1)$-transformations I have made the following observation:
$$L = \bar{\psi} (i\gamma^{\mu}\partial_\mu \psi -m)\psi.$$
I assume the following local gauge transformation: $\psi \longrightarrow e^{-i\alpha(x)} \psi$ ( and $\bar{\psi}\longrightarrow e^{i\alpha(x)} \bar{\psi})$:
$$L' =e^{i\alpha(x)}\bar{\psi}e^{-i\alpha(x)}(i\gamma^\mu\partial_\mu\psi+e\gamma^{\mu}(\partial_\mu\alpha) \psi) -m\bar{\psi}{\psi}$$
yields:
$$L' = L + e \bar{\psi}\gamma^\mu\psi \partial_\mu\alpha= L + e J^\mu \partial_\mu\alpha$$
where $J^{\mu}$ represents the 4-current density of the Dirac field. Now instead of introducing the gauge field $A_\mu$ I apply a partial integration and get:
$$\delta L = L'-L = e\partial_\mu(J^\mu \alpha) - e\partial_\mu J^\mu \alpha.$$
Applying two arguments:
under the action integral the partial derivative of the first term can be transformed into a surface integral at whose borders the current density $J^{\mu}$ vanishes.
due to current conservation the second term also vanishes. Therefore the Lagrangian (or at least the action) remains invariant under the local $U(1)$ transformation. What is the flaw of this conclusion?
BTW: I considered a similar argument for checking the gauge invariance of the coupling term $J^\mu A_\mu$ in the Maxwell equations. If $A_\mu$ is changed under gauge transformations one would get an additional term $J^\mu \partial_\mu \alpha$ which can be eliminated by the same strategy.
So if the first (invariance of the Dirac-equation without gauge field) does not work out, so how can work the second? Or would it mean that the Maxwell equations are not really gauge-invariant?