This is a very basic separable differential equation and can be easily solved as such:
$$\frac{dy}{dx}=xy;\,y(0)=2$$ $$\frac{dy}{dx}=xy$$ $$\frac{dy}{y}=xdx$$ $$\int\frac{dy}{y}=\int xdx$$ $$\ln|y|=\frac{x^2}{2}+C$$ $$y=Ke^\frac{x^2}{2};\,y(0)=2$$ $$2=Ke^\frac{0^2}{2}\therefore K=2$$ $$\therefore y=2e^\frac{x^2}{2}$$
I am wondering what other methods can be used to solve this problem and I intend for the answers of this question to become a compilation of these methods. I was able to solve it using Laplace Transforms and I will post it as an answer.
Using Laplace Transforms: $\require{cancel}$ $$y'=xy;y(0)=2$$ $$\mathscr{L}\left\{\frac{y'}{y}\right\}=\mathscr{L}\{x\}$$ $$\mathscr{L}\left\{\frac{y'}{y}\right\}=\mathscr{L}\left\{x\right\}=\frac{1}{s^2}$$ $$ \mathscr{L}\left\{\frac{y'}{y}\right\}= \int\limits_0^\infty\frac{\frac{dy}{\cancel{dx}}}{y}e^{-sx}\cancel{dx}= \int\limits_0^\infty\frac{e^{-sx}}{y}dy= \ln|y|e^{-sx}|_0^\infty+\int\limits_0^\infty\ln|y|se^{-sx}dx= \ln|y(0)|+s\mathscr{L}\{\ln|y|\}$$
$$\ln|2|+s\mathscr{L}\{\ln|y|\}=\frac{1}{s^2}$$ $$\mathscr{L}\{\ln|y|\}=\frac{1}{s^3}-\frac{\ln2}{s}$$ $$\ln|y|=\frac{x^2}{2}+\ln2$$ $$y=2e^\frac{x^2}{2}$$