LONDON - A month of the war in Ukraine briefly erased a year's worth of gains for European equities but the continent's bourses have quickly recovered as investors have poured money into sectors such as energy and defence which are poised to benefit from one of the deepest policy shifts in the region in decades.

The largest war in Europe since World War Two has suddenly awakened governments to the urgent need of making their economies less reliant on oil and gas imports from Russia and building their own military security capabilities.

After initially plunging to 12-month lows amid record outflows on worries the war could cause a stagflation shock, European equities have swiftly recovered. Shares in German defence company Rheinmetall are worth twice as much as before the conflict while shares of wind turbine maker Vestas Wind Systems have jumped around 40% so far.

The broader market has recovered 11% in one month, and is within striking distance of a record high on Jan. 4 with overall valuations at a 34% discount to the U.S. market.

"The TINA argument ("There is No Alternative" to stocks) is not as strong as it was but ... the yields you can get on many parts of the equity space - particularly energy, materials and financials - are still your better source of income at the moment," said Benjamin Jones, director of macro research at Invesco.

Investors' shopping bag has changed dramatically since Feb. 24 when Russia launched what it calls a "special military operation" in Ukraine.

"Europe will transition to be more independent and redefine many of its sectors and economic paradigms," said Eric Lopez, head of EMEA Equity Research at BofA Global Research.

"The consequences will range from the development of new industries, the acceleration of existing ones, additional infrastructure and technologies, while reaching independence and leadership for some," he said.

With its costly REpowerEU plan, the European Commission wants to replace over 70% of Russian gas imports this year by ramping up liquefied natural gas purchases, green energy and gas storage.

Investment flows at a regional level continue to be in negative territory for Europe with net outflows of $17.9 billion so far this year, according to BoFA.

But Morningstar data showed 2.1 billion euros of fund inflows to the European energy sector this year, while shares of a handful of European defence companies have attained double-digit returns since the start of the war.

Germany and Sweden said they plan to sharply increase spending on defence to around 2% of their economic output.

BofA estimates 200 billion euros ($218.08 billion) of incremental annual spending in the sector if all European countries moved to devote 2% of their gross domestic product spending on defence.

Commodity-linked stocks alongside financials shares have been the preferred sectors since the start of the war as oil and other commodity prices surged. Healthcare is back in vogue for its defensive traits.

"SO AWAY FROM THESE INDEXES"

Lale Akoner, senior market strategist at BNY Mellon Investment Management, said her top picks are commodity-rich London FTSE 100 and the Norwegian index. She is avoiding Germany's Dax, for its heavy exposure to Russian energy.

"What I'm saying to clients is that you have ... to understand the nuances on which country is more dependent on natural gas and energy supply from Russia," she said. "So away from these indexes".

There is a lot of investor interest in Europe's energy sector with the REPowerEU plan expected to be positive for pure renewables players like RWE, Orsted and EDP Renováveis.

Plans to speed up the development of alternative gas supplies and LNG will need supporting infrastructure, which could put E.ON, Italgas, Snam, Terna , Red Eléctrica and Enagás in the spotlight for potential network development.

"What's happened in Russia and Ukraine all of a sudden meant that the energy transition from fossil fuels to more renewables alternatives is now not just an environmental issue, it is also now a security issue as well," Invesco's Jones said. ($1 = 0.9171 euro)

(Reporting by Joice Alves in London and Danilo Masoni in Milan Editing by Saikat Chatterjee and Matthew Lewis)