Fortunately, you don't need a lot of money to invest in stocks. Whether you are getting started or adding to your portfolio, you can invest an amount that you can afford. Even if you start with a few shares, you can add to it over time.

If you have a spare $3,000 after paying your bills and setting up an emergency fund, these are good stocks to buy and hold for years.

Buttons labeled long-term, medium-term, and short-term with hand pressing long-term

Image source: Getty Images.

1. Disney

Walt Disney (DIS 0.18%) saw some of its businesses hurt last year, including curtailed attendance at its theme parks and less original television and movie content. Its revenue was down by 6% as the latter half of the year dragged down results. In its fiscal first quarter, which ended on Jan. 2, revenue was down by 22% to $16.2 billion.

Fortunately, Disney is a sprawling media empire with attractive businesses poised to regain traction. This includes worldwide theme parks, television and cable networks (including ABC and The Disney Channel), retail stores, and film production companies that include Disney, Twentieth Century Studios, Marvel, Lucasfilm, and Pixar.

With governments distributing coronavirus vaccines, people are becoming more optimistic that the worst is behind us. Next month, Disney has scheduled its California parks' reopening, albeit in a limited capacity. There is also its increasingly popular Disney+ streaming service that it launched in November 2019 and has rapidly grown to 94.9 million paid subscribers.

While the pandemic hurt results temporarily, with this collection of high-quality assets, it won't take long for the company to get back on track.

2. Johnson & Johnson

Johnson & Johnson (JNJ -0.69%) is comprised of three strong businesses. The largest sales generator is pharmaceutical, which accounts for 55% of its annual sales, producing treatments for areas such as heart disease, diabetes, and cancer. This continues to perform well, with adjusted sales growing by 14.6% last year. Its other two divisions are medical devices that medical professionals use in surgeries and orthopedics, and consumer, which has a host of well-recognized brands like Tylenol, Listerine, and Nicorette.

These are strong businesses, although some areas, most notably medical devices, were temporarily hurt by the pandemic due to doctors and patients canceling procedures. This unit's adjusted sales fall by 1.5%.

Last year, Johnson & Johnson's total sales were up by 7.3%, and it expects nearly 9% growth this year. This may very well prove conservative since management didn't include its recently approved COVID-19 vaccine in its forecast.

Plus, if you are also looking for dividends, Johnson & Johnson has raised payments annually for 58 straight years, making it a Dividend King, or a company with at least a 50-year streak. Generating about $20 billion of free cash flow annually, this is roughly double its yearly dividend payments. Johnson & Johnson's dividend yield is 2.5%.

3. Walmart

Walmart (WMT 1.32%) is not only the world's largest retailer, serving 240 million customers at its stores and websites weekly, but it is hugely profitable. Last year's adjusted revenue grew by 7.7%, driving its adjusted operating income 10.6% higher to $22.8 billion.

The company attracted customers with its broad selection and enviably low prices, giving it a distinct advantage over the competition. In fact, you are hard-pressed to find retailers that undercut Walmart's low prices.

Management has also been pushing technology that allows customers to order their merchandise in a variety of ways with multiple delivery options. It plans to continue investing in technological initiatives, which management cites as one reason next year's operating income will come in about the same as last year, despite a low-single-digit percentage increase in sales.

But Walmart can afford to make these investments, allowing it to continue reaching customers in a variety of ways.

It generates a prodigious amount of free cash flow, which was $25.8 billion last year. It uses part of this to reward shareholders with dividends, totaling $6.1 billion. In February, Walmart increased its quarterly dividends by a penny to $0.55, marking 48 straight years that it has boosted payments. The stock's yield is 1.6%.

These accomplished companies are each well positioned for future success. While investing $3,000 may not seem like a lot of money, it's a start. These investments will allow you to sit back and grow your wealth over time while providing a sense of security in your investment.